Module malachite_base::num::arithmetic
source · [−]Expand description
Traits for arithmetic.
Modules
Abs
, AbsAssign
, and
UnsignedAbs
, traits for getting the absolute value of a number.
AddMul
and AddMulAssign
, traits for adding a
number and the product of two other numbers.
ArithmeticCheckedShl
, a trait for left-shifting a number and
checking whether the result is representable.
ArithmeticCheckedShr
, a trait for right-shifting a number and
checking whether the result is representable.
Ceiling
and CeilingAssign
, traits for computing
the ceiling of a number.
CheckedAbs
, a trait for computing the absolute value of number and
checking whether the result is representable.
CheckedAdd
, a trait for adding two numbers and checking whether the
result is representable.
CheckedAddMul
, a trait for adding a number and the product of two
other numbers, and checking whether the result is representable.
CheckedDiv
, a trait for dividing two numbers and checking whether the
result is representable.
CheckedMul
, a trait for multiplying two numbers and checking whether
the result is representable.
CheckedNeg
, a trait for negating a number and checking whether the
result is representable.
CheckedNextPowerOf2
, a trait for getting the next-highest
power of 2, if it’s representable.
CheckedPow
, a trait for raising a number to the power of a u64
and
checking whether the result is representable.
CheckedSquare
, a trait for squaring a number and checking whether
the result is representable.
CheckedSub
, a trait for subtracting two numbers and checking whether
the result is representable.
CheckedSubMul
, a trait for subtracting the product of two numbers
from another number, and checking whether the result is representable.
CoprimeWith
, a trait for determining whether two numbers are coprime.
DivExact
and DivExactAssign
, traits for
dividing two numbers when it’s known that the division is exact.
Traits for simultaneously finding the quotient and remainder of two numbers, subject to various rounding rules.
DivRound
and DivExactAssign
, traits for
dividing two numbers according to a specified
RoundingMode
.
DivisibleBy
, a trait for determining whether one number is divisible
by another.
DivisibleByPowerOf2
, a trait for determining whether a number
is divisible by $2^k$.
EqModPowerOf2
, a trait for determining whether one number is equal
to another modulo $2^k$.
ExtendedGcd
, a trait for computing the GCD (greatest common divisor)
of two numbers as well as the coefficients of Bézout’s identity $ax+by=\gcd(a,b)$.
Floor
and FloorAssign
, traits for computing the
floor of a number.
IsPowerOf2
, a trait for determining whether a number is an integer
power of 2.
Lcm
, LcmAssign
, and CheckedLcm
,
traits for computing the LCM (least common multiple) of two numbers.
Traits for taking the base-$b$ logarithm of a number.
Traits for taking the base-2 logarithm of a number.
Traits for taking the base-$2^k$ logarithm of a number.
ModAdd
and ModAddAssign
, traits for adding two
numbers modulo another number.
ModInverse
, a trait for finding the multiplicative inverse of a number
modulo another number.
ModIsReduced
, a trait for checking whether a number is reduced modulo
another number.
Traits for multiplying two numbers modulo another number.
ModNeg
and ModNegAssign
, traits for negating a
number modulo another number.
Traits for finding the remainder of two numbers, subject to various rounding rules.
Traits for raising a number to a power modulo another number.
Traits for finding the remainder of a number divided by $2^k$, subject to various rounding rules.
ModPowerOf2Add
and
ModPowerOf2AddAssign
, traits for adding two numbers modulo
$2^k$.
ModPowerOf2Inverse
, a trait for finding the multiplicative
inverse of a number modulo $2^k$.
ModPowerOf2IsReduced
, a trait for checking whether a number
is reduced modulo $2^k$.
ModPowerOf2Mul
and
ModPowerOf2MulAssign
, traits for multiplying two numbers
modulo $2^k$.
ModPowerOf2Neg
and
ModPowerOf2NegAssign
, traits for negating a number modulo
$2^k$.
ModPowerOf2Pow
and
ModPowerOf2PowAssign
, traits for raising a number to a power
modulo $2^k$.
ModPowerOf2Shl
and
ModPowerOf2ShlAssign
, traits for left-shifting a number
modulo $2^k$.
ModPowerOf2Shr
and
ModPowerOf2ShrAssign
, traits for right-shifting a number
modulo $2^k$.
ModPowerOf2Square
and
ModPowerOf2SquareAssign
, traits for squaring a number
modulo $2^k$.
ModPowerOf2Sub
and
ModPowerOf2SubAssign
, traits for subtracting one number by
another modulo $2^k$.
ModShl
and ModShlAssign
, traits for left-shifting
a number modulo another number.
ModShr
and ModShrAssign
, traits for
right-shifting a number modulo another number.
Traits for squaring a number modulo another number.
ModSub
and ModSubAssign
, traits for subtracting
two numbers modulo another number.
NextPowerOf2
and NextPowerOf2Assign
,
traits for getting the next-highest power of 2.
OverflowingAbs
and
OverflowingAbsAssign
, traits for taking the absolute value
of a number and returning a boolean indicating whether an overflow occurred.
OverflowingAdd
and
OverflowingAddAssign
, traits for adding two numbers and
returning a boolean indicating whether an overflow occurred.
OverflowingAddMul
and
OverflowingAddMulAssign
, traits for adding the product of
two other numbers to a number and returning a boolean indicating whether an overflow occurred.
OverflowingDiv
and
OverflowingDivAssign
, traits for dividing two numbers and
returning a boolean indicating whether an overflow occurred.
OverflowingMul
and
OverflowingMulAssign
, traits for multiplying two numbers and
returning a boolean indicating whether an overflow occurred.
OverflowingNeg
and
OverflowingNegAssign
, traits for negating a number and
returning a boolean indicating whether an overflow occurred.
OverflowingPow
and
OverflowingPowAssign
, traits for raising a number to a power
and returning a boolean indicating whether an overflow occurred.
OverflowingSquare
and
OverflowingSquareAssign
, traits for squaring a number and
returning a boolean indicating whether an overflow occurred.
OverflowingSub
and
OverflowingSubAssign
, traits for subtracting two numbers and
returning a boolean indicating whether an overflow occurred.
OverflowingSubMul
and
OverflowingSubMulAssign
, traits for subtracting the
product of two other numbers from a number and returning a boolean indicating whether an
overflow occurred.
PowerOf2
, a trait for computing a power of 2.
Traits for taking the $n$th root of a number.
RoundToMultiple
and
RoundToMultipleAssign
, traits for rounding a number to a
multiple of another number.
RoundToMultipleOfPowerOf2
and
RoundToMultipleOfPowerOf2Assign
, traits for
rounding a number to a multiple of a power of 2.
SaturatingAbs
and
SaturatingAbsAssign
, traits for taking the absolute value of a
number and saturating at numeric bounds instead of overflowing.
SaturatingAdd
and
SaturatingAddAssign
, traits for adding two numbers and
saturating at numeric bounds instead of overflowing.
SaturatingAddMul
and
SaturatingAddMulAssign
, traits for adding the product of
two numbers to a number and saturating at numeric bounds instead of overflowing.
SaturatingMul
and
SaturatingMulAssign
, traits for multiplying two numbers and
saturating at numeric bounds instead of overflowing.
SaturatingNeg
and
SaturatingNegAssign
, traits for negating a number and
saturating at numeric bounds instead of overflowing.
SaturatingPow
and
SaturatingPowAssign
, traits for raising a number to a power
and saturating at numeric bounds instead of overflowing.
SaturatingSquare
and
SaturatingSquareAssign
, traits for squaring a number and
saturating at numeric bounds instead of overflowing.
SaturatingSub
and
SaturatingSubAssign
, traits for subtracting two numbers and
saturating at numeric bounds instead of overflowing.
SaturatingSubMul
and
SaturatingSubMulAssign
, traits for subtracting a number by
the product of two numbers and saturating at numeric bounds instead of overflowing.
ShlRound
and ShlRoundAssign
, traits for
multiplying a number by a power of 2 and rounding according to a specified
RoundingMode
.
ShrRound
and ShrRoundAssign
, traits for
dividing a number by a power of 2 and rounding according to a specified
RoundingMode
.
Traits for taking the square root of a number.
Square
and SquareAssign
, traits for squaring a
number.
SubMul
and SubMulAssign
, traits for subtracting
the product of two numbers from a number.
Various traits for performing arithmetic operations on numbers.
WrappingAbs
and WrappingAbsAssign
,
traits for computing the absolute value of a number and wrapping at the boundary of the type.
WrappingAdd
and WrappingAddAssign
,
traits for adding two numbers and wrapping at the boundary of the type.
WrappingAddMul
and
WrappingAddMulAssign
, traits for adding the product of two
numbers to a third and wrapping at the boundary of the type.
WrappingDiv
and WrappingDivAssign
,
traits for dividing two numbers and wrapping at the boundary of the type.
WrappingMul
and WrappingMulAssign
,
traits for multiplying two numbers and wrapping at the boundary of the type.
WrappingNeg
and WrappingNegAssign
for
negating a number and wrapping at the boundary of the type.
WrappingPow
and WrappingPowAssign
,
traits for raising a number to a power and wrapping at the boundary of the type.
WrappingSquare
and
WrappingSquareAssign
, traits for squaring a number and wrapping
at the boundary of the type.
WrappingSub
and WrappingSubAssign
,
traits for subtracting two numbers and wrapping at the boundary of the type.
WrappingSubMul
and
WrappingSubMulAssign
, traits for subtracting a number by the
product of two other numbers and wrapping at the boundary of the type.
XMulYToZZ
, a trait for multiplying two numbers and returning the result
as a double-width number.
XXAddYYToZZ
, a trait for adding two double-width numbers and returning
the result as a double-width number.
XXDivModYToQR
, a trait for dividing a double-width number by a
single-width number and returning the quotient and remainder.
XXSubYYToZZ
, a trait for subtracting two double-width numbers and
returning the result as a double-width number.
XXXAddYYYToZZZ
, a trait for adding two triple-width numbers and
returning the result as a triple-width number.
XXXSubYYYToZZZ
, a trait for subtracting two triple-width numbers
and returning the result as a triple-width number.
XXXXAddYYYYToZZZZ
, a trait for adding two quadruple-width
numbers and returning the result as a quadruple-width number.