Skip to main content

Module primitives

Module primitives 

Source

Functionsยง

borrowing_sub ๐Ÿ”’
Computes lhs - (rhs + borrow), returning the result along with the new borrow.
carrying_add ๐Ÿ”’
Computes lhs + rhs + carry, returning the result along with the new carry (0, 1, or 2).
carrying_mul_add ๐Ÿ”’
Computes (lhs * rhs) + addend + carry, returning the result along with the new carry.
overflowing_add ๐Ÿ”’
Computes lhs + rhs, returning the result along with the carry (0 or 1).
u32_bits ๐Ÿ”’
Compute the number of bits needed to represent n.
u32_max ๐Ÿ”’
const fn equivalent of u32::max(a, b).
u32_min ๐Ÿ”’
const equivalent of u32::min(a, b).
u32_rem ๐Ÿ”’
Remainder calculation, constant time for a given divisor d. Based on โ€œFaster Remainder by Direct Computation: Applications to Compilers and Software Librariesโ€ by Daniel Lemire, Owen Kaser, and Nathan Kurz., Fig. 1.
u64_invert_odd ๐Ÿ”’
Returns the multiplicative inverse of the argument modulo 2^64. The implementation is based on Hurchallaโ€™s method for computing the multiplicative inverse modulo a power of two, and is essentially an optimized Newton iteration.
usize_lt ๐Ÿ”’
Return a Choice representing whether a < b.
widening_mul ๐Ÿ”’
Computes lhs * rhs, returning the low and the high words of the result.