Expand description

Various traits for performing arithmetic operations on numbers.

Traits

Takes the absolute value of a number. Assumes that the number has a representable absolute number.

Replaces a number with its absolute value. Assumes that the number has a representable absolute number.

Adds a number and the product of two other numbers.

Adds a number and the product of two other numbers, in place.

Left-shifts a number (multiplies it by a power of 2), returning None if the result is not representable.

Right-shifts a number (divides it by a power of 2), returning None if the result is not representable.

Takes the ceiling of a number.

Replaces a number with its ceiling.

Divides a number by another number in place, taking the quotient and returning the remainder. The quotient is rounded towards positive infinity and the remainder has the opposite sign of the divisor (second input).

Divides a number by another number in place, taking the ceiling of the quotient and returning the remainder of the negative of the first number divided by the second.

Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards positive infinity and the remainder has the opposite sign as the divisor (second input).

Divides a number by another number, returning the ceiling of the quotient and the remainder of the negative of the first number divided by the second.

Calculates the ceiling of the base-$b$ logarithm of a number.

Calculates the ceiling of the base-2 logarithm of a number.

Calculates the ceiling of the base-$2^k$ logarithm of a number.

Divides a number by another number, returning just the remainder. The remainder has the opposite sign as the divisor (second number).

Divides a number by another number, replacing the first number by the remainder. The remainder has the same sign as the divisor (second number).

Divides a number by $2^k$, returning just the remainder. The remainder is non-positive.

Divides a number by $2^k$, replacing the number by the remainder. The remainder is non-positive.

Finds the ceiling of the $n$th root of a number.

Replaces a number with the ceiling of its $n$th root.

Finds the ceiling of the square root of a number.

Replaces a number with the ceiling of its square root.

Takes the absolute valie of a number, returning None if the result is not representable.

Adds two numbers, returning None if the result is not representable.

Adds a number and the product of two other numbers, returning None if the result is not representable.

Divides two numbers, returning None if the result is not representable.

Calculates the LCM (least common multiple) of two numbers, returning None if the result is not representable.

Calculates the base-$b$ logarithm of a number, or returns None if the number is not a perfect power of $b$.

Calculates the base-2 logarithm of a number, or returns None if the number is not a perfect power of 2.

Calculates the base-$2^k$ logarithm of a number, or returns None if the number is not a perfect power of $2^k$.

Multiplies two numbers, returning None if the result is not representable.

Negates a number, returning None if the result is not representable.

Finds the smallest integer power of 2 greater than or equal to a number, returning None if the result is not representable.

Raises a number to a power, returning None if the result is not representable.

Finds the $n$th root of a number, returning None if it is not a perfect $n$th power.

Finds the square root of a number, returning None if it is not a perfect square.

Squares a number, returning None if the result is not representable.

Subtracts two numbers, returning None if the result is not representable.

Subtracts a number by the product of two other numbers, returning None if the result is not representable.

Determines whether two numbers are coprime.

Divides a number by another number in place, returning the remainder. The quotient is rounded towards negative infinity, and the remainder has the same sign as the divisor (second input).

Divides a number by another number in place, returning the remainder. The quotient is rounded towards zero, and the remainder has the same sign as the dividend (first input).

Divides two numbers, assuming the first exactly divides the second.

Divides a number by another number in place, assuming the first exactly divides the second.

Divides two numbers, returning the quotient and remainder. The quotient is rounded towards negative infinity, and the remainder has the same sign as the divisor (second input).

Divides two numbers, returning the quotient and remainder. The quotient is rounded towards zero, and the remainder has the same sign as the dividend (first input).

Divides a number by another number and rounds according to a specified rounding mode.

Divides a number by another number in place and rounds according to a specified rounding mode.

Determines whether a number is divisible by another number.

Determines whether a number is divisible by $2^k$.

Determines whether a number is equivalent to another number modulo $m$.

Determines whether a number is equivalent to another number modulo $2^k$.

Takes the floor of a number.

Replaces a number with its floor.

Calculates the floor of the base-$b$ logarithm of a number.

Calculates the floor of the base-2 logarithm of a number.

Calculates the floor of the base-$2^k$ logarithm of a number.

Finds the floor of the $n$th root of a number.

Replaces a number with the floor of its $n$th root.

Finds the floor of the square root of a number.

Replaces a number with the floor of its square root.

Calculates the GCD (greatest common divisor) of two numbers.

Replaces a number with the GCD (greatest common divisor) of it and another number.

Determines whether a number is an integer power of 2.

Calculates the LCM (least common multiple) of two numbers.

Replaces a number with the LCM (least common multiple) of it and another number.

Divides a number by another number, returning just the remainder. The remainder has the same sign as the divisor (second number).

Adds two numbers modulo a third number $m$. Assumes the inputs are already reduced modulo $m$.

Adds two numbers modulo a third number $m$, in place. Assumes the inputs are already reduced modulo $m$.

Divides a number by another number, replacing the first number by the remainder. The remainder has the same sign as the divisor (second number).

Checks whether a number is reduced modulo another number $m$.

Multiplies two numbers modulo a third number $m$. Assumes the inputs are already reduced mod $m$.

Multiplies two numbers modulo a third number $m$, in place. Assumes the inputs are already reduced modulo $m$.

Multiplies two numbers modulo a third number $m$. Assumes the inputs are already reduced mod $m$.

Multiplies two numbers modulo a third number $m$, in place. Assumes the inputs are already reduced modulo $m$.

Negates a number modulo another number $m$. Assumes the input is already reduced modulo $m$.

Negates a number modulo another number $m$, in place. Assumes the input is already reduced modulo $m$.

Raises a number to a power modulo another number $m$. Assumes the input is already reduced modulo $m$.

Raises a number to a power modulo another number $m$, in place. Assumes the input is already reduced modulo $m$.

Raises a number to a power modulo another number $m$. Assumes the input is already reduced modulo $m$.

Raises a number to a power modulo another number $m$, in place. Assumes the input is already reduced modulo $m$.

Divides a number by $2^k$, returning just the remainder. The remainder is non-negative.

Adds two numbers modulo $2^k$. Assumes the inputs are already reduced modulo $2^k$.

Adds two numbers modulo $2^k$, in place. Assumes the inputs are already reduced modulo $2^k$.

Divides a number by $2^k$, replacing the number by the remainder. The remainder is non-negative.

Checks whether a number is reduced modulo $2^k$.

Multiplies two numbers modulo $2^k$. Assumes the inputs are already reduced modulo $2^k$.

Multiplies two numbers modulo $2^k$, in place. Assumes the inputs are already reduced modulo $2^k$.

Negates a number modulo $2^k$. Assumes the input is already reduced modulo $2^k$.

Negates a number modulo $2^k$ in place. Assumes the input is already reduced modulo $2^k$.

Raises a number to a power modulo $2^k$. Assumes the input is already reduced modulo $2^k$.

Raises a number to a power modulo $2^k$, in place. Assumes the input is already reduced modulo $2^k$.

Left-shifts a number (multiplies it by a power of 2) modulo $2^k$. Assumes the input is already reduced modulo $2^k$.

Left-shifts a number (multiplies it by a power of 2) modulo $2^k$, in place. Assumes the input is already reduced modulo $2^k$.

Right-shifts a number (divides it by a power of 2) modulo $2^k$. Assumes the input is already reduced modulo $2^k$.

Right-shifts a number (divides it by a power of 2) modulo $2^k$, in place. Assumes the input is already reduced modulo $2^k$.

Squares a number modulo $2^k$. Assumes the input is already reduced modulo $2^k$.

Squares a number modulo $2^k$ in place. Assumes the input is already reduced modulo $2^k$.

Subtracts two numbers modulo $2^k$. Assumes the inputs are already reduced modulo $2^k$.

Subtracts two numbers modulo $2^k$, in place. Assumes the inputs are already reduced modulo $2^k$.

Left-shifts a number (multiplies it by a power of 2) modulo another number $m$. Assumes the input is already reduced modulo $m$.

Left-shifts a number (multiplies it by a power of 2) modulo another number $m$, in place. Assumes the input is already reduced modulo $m$.

Left-shifts a number (divides it by a power of 2) modulo another number $m$. Assumes the input is already reduced modulo $m$.

Left-shifts a number (divides it by a power of 2) modulo another number $m$, in place. Assumes the input is already reduced modulo $m$.

Squares a number modulo another number $m$. Assumes the input is already reduced modulo $m$.

Squares a number modulo another number $m$, in place. Assumes the input is already reduced modulo $m$.

Squares a number modulo another number $m$. Assumes the input is already reduced modulo $m$.

Squares a number modulo another number $m$, in place. Assumes the input is already reduced modulo $m$.

Adds two numbers modulo a third number $m$. Assumes the inputs are already reduced modulo $m$.

Adds two numbers modulo a third number $m$, in place. Assumes the inputs are already reduced modulo $m$.

Replaces a number with its negative. Assumes the result is representable.

Divides the negative of a number by another number, returning the remainder.

Divides the negative of a number by another number, replacing the first number by the remainder.

Divides the negative of a number by $2^k$, returning the remainder.

Divides the negative of a number by $2^k$, replacing the number by the remainder.

Returns the smallest power of 2 greater than or equal to a number. Assumes the result is representable.

Replaces a number with the smallest power of 2 greater than or equal it. Assumes the result is representable.

Takes the absolute value of a number.

Replaces a number with its absolute value.

Adds two numbers.

Adds a number to another number in place.

Adds a number and the product of two other numbers.

Adds a number and the product of two other numbers, in place.

Divides two numbers.

Divides a number by another number in place.

Multiplies two numbers.

Multiplies a number by another number in place.

Negates a number.

Negates a number in place.

Raises a number to a power.

Raises a number to a power in place.

Squares a number.

Squares a number in place.

Subtracts two numbers.

Subtracts a number by another number in place.

Subtracts a number by the product of two other numbers.

Subtracts a number by the product of two other numbers, in place.

Determines whether a number is even or odd.

Raises a number to a power. Assumes the result is representable.

Raises a number to a power in place. Assumes the result is representable.

Raises 2 to a power.

Finds the reciprocal (multiplicative inverse) of a number.

Replaces a number with its reciprocal (multiplicative inverse).

Divides a number by $2^k$, returning just the remainder. The remainder has the same sign as the number.

Divides a number by $2^k$, replacing the number by the remainder. The remainder has the same sign as the number.

Replaces a number with the floor of its $n$th root, returning the remainder.

Finds the floor of the $n$th root of a number, returning both the root and the remainder.

Rounds a number to a multiple of another number, according to a specified rounding mode.

Rounds a number to a multiple of another number in place, according to a specified rounding mode.

Rounds a number to a multiple of $2^k$, according to a specified rounding mode.

Rounds a number to a multiple of $2^k$ in place, according to a specified rounding mode.

Takes the absolute value of a number, saturating at the numeric bounds instead of overflowing.

Replaces a number with its absolute value, saturating at the numeric bounds instead of overflowing.

Adds two numbers, saturating at the numeric bounds instead of overflowing.

Add a number to another number in place, saturating at the numeric bounds instead of overflowing.

Adds a number and the product of two other numbers, saturating at the numeric bounds instead of overflowing.

Adds a number and the product of two other numbers in place, saturating at the numeric bounds instead of overflowing.

Multiplies two numbers, saturating at the numeric bounds instead of overflowing.

Multiplies a number by another number in place, saturating at the numeric bounds instead of overflowing.

Negates a number, saturating at the numeric bounds instead of overflowing.

Negates a number in place, saturating at the numeric bounds instead of overflowing.

Raises a number to a power, saturating at the numeric bounds instead of overflowing.

Raises a number to a power in place, saturating at the numeric bounds instead of overflowing.

Squares a number, saturating at the numeric bounds instead of overflowing.

Squares a number in place, saturating at the numeric bounds instead of overflowing.

Subtracts two numbers, saturating at the numeric bounds instead of overflowing.

Subtracts a number by another number in place, saturating at the numeric bounds instead of overflowing.

Subtracts a number by the product of two other numbers, saturating at the numeric bounds instead of overflowing.

Subtracts a number by the product of two other numbers in place, saturating at the numeric bounds instead of overflowing.

Left-shifts a number (multiplies it by a power of 2), rounding the result according to a specified rounding mode.

Left-shifts a number (multiplies it by a power of 2) in place, rounding the result according to a specified rounding mode.

Right-shifts a number (divides it by a power of 2), rounding the result according to a specified rounding mode.

Right-shifts a number (divides it by a power of 2) in place, rounding the result according to a specified rounding mode.

Returns Greater, Equal, or Less, depending on whether a number is positive, zero, or negative, respectively.

Takes the square root of a number.

Replaces a number with its square root.

Replaces a number with the floor of its square root, returning the remainder.

Finds the floor of the square root of a number, returning both the root and the remainder.

Squares a number.

Replaces a number with its square.

Subtracts a number by the product of two other numbers.

Subtracts a number by the product of two other numbers, in place.

Takes the absolute value of a number and converts to the unsigned equivalent.

Takes the absolute value of a number, wrapping around at the boundary of the type.

Replaces a number with its absolute value, wrapping around at the boundary of the type.

Adds two numbers, wrapping around at the boundary of the type.

Adds a number to another number in place, wrapping around at the boundary of the type.

Adds a number and the product of two other numbers, wrapping around at the boundary of the type.

Adds a number and the product of two other numbers, in place, wrapping around at the boundary of the type.

Divides a number by another number, wrapping around at the boundary of the type.

Divides a number by another number in place, wrapping around at the boundary of the type.

Multiplies two numbers, wrapping around at the boundary of the type.

Multiplies a number by another number in place, wrapping around at the boundary of the type.

Negates a number, wrapping around at the boundary of the type.

Negates a number in place, wrapping around at the boundary of the type.

Raises a number to a power, wrapping around at the boundary of the type.

Raises a number to a power in place, wrapping around at the boundary of the type.

Squares a number, wrapping around at the boundary of the type.

Squares a number in place, wrapping around at the boundary of the type.

Subtracts two numbers, wrapping around at the boundary of the type.

Subtracts a number by another number in place, wrapping around at the boundary of the type.

Subtracts a number by the product of two other numbers, wrapping around at the boundary of the type.

Subtracts a number by the product of two other numbers, in place, wrapping around at the boundary of the type.

Multiplies two numbers, returning the product as a pair of Self values.

Adds two numbers, each composed of two Self values, returning the sum as a pair of Self values.

Computes the quotient and remainder of two numbers. The first is composed of two Self values, and the second of a single one.

Subtracts two numbers, each composed of two Self values, returing the difference as a pair of Self values.

Adds two numbers, each composed of three Self values, returning the sum as a triple of Self values.

Subtracts two numbers, each composed of three Self values, returing the difference as a triple of Self values.

Adds two numbers, each composed of four Self values, returning the sum as a quadruple of Self values.