Checked Math
Base.Checked
Base.Checked.checked_abs
Base.Checked.checked_neg
Base.Checked.checked_add
Base.Checked.checked_sub
Base.Checked.checked_mul
Base.Checked.checked_div
Base.Checked.checked_rem
Base.Checked.checked_fld
Base.Checked.checked_mod
Base.Checked.checked_cld
With Overflow
index
Base.Checked
— ModuleChecked
The Checked module provides arithmetic functions for the built-in signed and unsigned Integer types which throw an error when an overflow occurs. They are named like checked_sub
, checked_div
, etc. In addition, add_with_overflow
, sub_with_overflow
, mul_with_overflow
return both the unchecked results and a boolean value denoting the presence of an overflow.
Base.Checked.checked_abs
— FunctionBase.checked_abs(x)
Calculates abs(x)
, checking for overflow errors where applicable. For example, standard two's complement signed integers (e.g. Int
) cannot represent abs(typemin(Int))
, thus leading to an overflow.
The overflow protection may impose a perceptible performance penalty.
Base.Checked.checked_neg
— FunctionBase.checked_neg(x)
Calculates -x
, checking for overflow errors where applicable. For example, standard two's complement signed integers (e.g. Int
) cannot represent -typemin(Int)
, thus leading to an overflow.
The overflow protection may impose a perceptible performance penalty.
Base.Checked.checked_add
— FunctionBase.checked_add(x, y)
Calculates x+y
, checking for overflow errors where applicable.
The overflow protection may impose a perceptible performance penalty.
Base.Checked.checked_sub
— FunctionBase.checked_sub(x, y)
Calculates x-y
, checking for overflow errors where applicable.
The overflow protection may impose a perceptible performance penalty.
Base.Checked.checked_mul
— FunctionBase.checked_mul(x, y)
Calculates x*y
, checking for overflow errors where applicable.
The overflow protection may impose a perceptible performance penalty.
Base.Checked.checked_div
— FunctionBase.checked_div(x, y)
Calculates div(x,y)
, checking for overflow errors where applicable.
The overflow protection may impose a perceptible performance penalty.
Base.Checked.checked_rem
— FunctionBase.checked_rem(x, y)
Calculates x%y
, checking for overflow errors where applicable.
The overflow protection may impose a perceptible performance penalty.
Base.Checked.checked_fld
— FunctionBase.checked_fld(x, y)
Calculates fld(x,y)
, checking for overflow errors where applicable.
The overflow protection may impose a perceptible performance penalty.
Base.Checked.checked_mod
— FunctionBase.checked_mod(x, y)
Calculates mod(x,y)
, checking for overflow errors where applicable.
The overflow protection may impose a perceptible performance penalty.
Base.Checked.checked_cld
— FunctionBase.checked_cld(x, y)
Calculates cld(x,y)
, checking for overflow errors where applicable.
The overflow protection may impose a perceptible performance penalty.
Base.Checked.add_with_overflow
— FunctionBase.add_with_overflow(x, y) -> (r, f)
Calculates r = x+y
, with the flag f
indicating whether overflow has occurred.
Base.Checked.sub_with_overflow
— FunctionBase.sub_with_overflow(x, y) -> (r, f)
Calculates r = x-y
, with the flag f
indicating whether overflow has occurred.
Base.Checked.mul_with_overflow
— FunctionBase.mul_with_overflow(x, y) -> (r, f)
Calculates r = x*y
, with the flag f
indicating whether overflow has occurred.