Expand description
Traits for arithmetic.
Modules§
- abs
- Absolute value of
Integers, including implementations ofUnsignedAbs. - abs_
diff - Implementations of
AbsDiffandAbsDiffAssign, traits for getting the absolute value of the difference between two numbers. - abs_
squared - Implementations of
AbsSquaredandAbsSquaredAssign, traits for computing the squared absolute value of a number. For real types this is the same as squaring. - add
- Addition of
Integers. - add_mul
- Implementations of
AddMulandAddMulAssign, traits for adding a number and the product of two other numbers. - average
Average,AverageAssign,AverageRound, andAverageRoundAssign, traits for computing the average (arithmetic mean) of two numbers.- balanced_
mod BalancedModandBalancedModAssign, traits for finding the representative of a number modulo another number that is closest to zero.- binomial_
coefficient - Implementations of
BinomialCoefficient, a trait for computing the binomial coefficient of two numbers. - canonical_
unit_ i_ pow - An implementation of
CanonicalUnitIPow, a trait for finding the power of $i$ that brings a number into canonical unit form. - canonicalize_
unit - Implementations of
CanonicalizeUnitandCanonicalizeUnitAssign, traits for bringing a number into canonical unit form. - conjugate
- Implementations of
ConjugateandConjugateAssign, traits for computing the complex conjugate of a number. A real number is its own conjugate. - crt
- Implementations of
BalancedCrt, a trait for combining two congruences by the Chinese remainder theorem and returning the representative of smallest absolute value. - div
- Division of
Integers. - div_
euclidean - Implementations of
DivEuclideanandDivEuclideanAssign, traits for finding the quotient of two numbers, rounded so that the remainder would be nonnegative. - div_
exact - Implementations of
DivExactandDivExactAssign, traits for dividing two numbers when it’s known that the division is exact. - div_mod
- Implementations of traits for simultaneously finding the quotient and remainder of two numbers, subject to various rounding rules.
- div_
mod_ euclidean - Implementations of
DivModEuclideanandDivAssignModEuclidean, traits for simultaneously finding the quotient and remainder of two numbers, where the remainder is nonnegative. - div_
round - Implementations of
DivRoundandDivExactAssign, traits for dividing two numbers according to a specifiedRoundingMode. - divisible_
by - Implementations of
DivisibleBy, a trait for determining whether one number is divisible by another. - divisible_
by_ power_ of_ 2 - Implementations of
DivisibleByPowerOf2, a trait for determining whether a number is divisible by $2^k$. - eq_mod
- Implementations of
EqMod, a trait for determining whether one number is equal by another modulo a third. - eq_
mod_ power_ of_ 2 - Implementations of
EqModPowerOf2, a trait for determining whether one number is equal to another modulo $2^k$. - extended_
gcd - Implementations of
ExtendedGcd, a trait for computing the extended GCD of two numbers. - falling_
factorial - Implementations of
FallingFactorial, a trait for computing the falling factorial of a number. - gcd
- Implementations of
GcdandGcdAssign, traits for computing the GCD (greatest common divisor) of two numbers. - is_
power_ of_ 2 - An implementation of
IsPowerOf2, a trait for determining whether a number is an integer power of 2. - is_unit
- An implementation of
IsUnit, a trait for determining whether a number is a unit of its ring. - kronecker_
symbol - Implementations of
LegendreSymbol,JacobiSymbol, andKroneckerSymbol, traits for computing the Legendre, Jacobi, and Kronecker symbols of two numbers. - mod_
euclidean - Implementations of
ModEuclideanandModEuclideanAssign, traits for finding the remainder of two numbers, where the remainder is nonnegative. - mod_op
- Implementations of traits for finding the remainder of two numbers, subject to various rounding rules.
- mod_
power_ of_ 2 - Implementations of traits for finding the remainder of a number divided by $2^k$, subject to various rounding rules.
- mul
- Multiplication of
Integers. - mul_
add_ mul - mul_
shr_ round - Implementations of
MulShrRoundandMulShrRoundAssign, traits for multiplying two numbers and right-shifting the product with a specified rounding mode. When most of the product is discarded, a short product avoids computing the rest. - mul_
sub_ mul - multi_
crt - Negation of an
Integer. The one-shot balanced multi-modulus Chinese remainder combination,Integer::multi_balanced_crt. - neg
- parity
- Implementations of
Parity, a trait for determining whether a number is even or odd. - pow
- Implementations of
PowandPowAssign, traits for raising a number to a power. - power_
of_ 2 - Implementations of
PowerOf2, a trait for computing a power of 2. - rising_
factorial - Implementations of
RisingFactorial, a trait for computing the rising factorial of a number. - root
- Implementations of traits for taking the $n$th root of a number.
- round_
to_ multiple - Implementations of
RoundToMultipleandRoundToMultipleAssign, traits for rounding a number to a multiple of another number. - round_
to_ multiple_ of_ power_ of_ 2 - Implementations of
RoundToMultipleOfPowerOf2andRoundToMultipleOfPowerOf2Assign, traits for rounding a number to a multiple of a power of 2. - shl
- Left-shifting an
Integer(multiplying it by a power of 2). - shl_
round - Implementations of
ShlRoundandShlRoundAssign, traits for multiplying a number by a power of 2 and rounding according to a specifiedRoundingMode. - shr
- Right-shifting an
Integer(dividing it by a power of 2). - shr_
round - Implementations of
ShrRoundandShrRoundAssign, traits for dividing a number by a power of 2 and rounding according to a specifiedRoundingMode. - sign
- Implementations of
Sign, a trait for determining the sign of a number. - sqrt
- Implementations of traits for taking the square root of a number.
- square
- Implementations of
SquareandSquareAssign, traits for squaring a number. - sub
- Subtraction of
Integers. - sub_mul
- Implementations of
SubMulandSubMulAssign, traits for subtracting the product of two numbers from a number.