Module malachite_nz::natural::arithmetic::mod_power_of_2
source · [−]Expand description
Implementations of traits for finding the remainder of a number divided by $2^k$, subject to various rounding rules.
These are the traits:
rounding | by value or reference | by mutable reference (assignment) |
---|---|---|
towards $-\infty$ | ModPowerOf2 | ModPowerOf2Assign |
towards 0 | RemPowerOf2 | RemPowerOf2Assign |
towards $\infty$ | NegModPowerOf2 | NegModPowerOf2Assign |
NegModPowerOf2
returns a remainder
greater than or equal to zero. This allows the remainder to have an unsigned type, but modifies
the usual relation $x = q2^k + r$ to $x = q2^k - r$.