Module malachite_base::num::arithmetic::mod_power_of_2_square
source · Expand description
ModPowerOf2Square
and
ModPowerOf2SquareAssign
, traits for squaring a number
modulo $2^k$.
§mod_power_of_2_square
use malachite_base::num::arithmetic::traits::ModPowerOf2Square;
assert_eq!(5u8.mod_power_of_2_square(3), 1);
assert_eq!(100u32.mod_power_of_2_square(8), 16);
§mod_power_of_2_square_assign
use malachite_base::num::arithmetic::traits::ModPowerOf2SquareAssign;
let mut n = 5u8;
n.mod_power_of_2_square_assign(3);
assert_eq!(n, 1);
let mut n = 100u32;
n.mod_power_of_2_square_assign(8);
assert_eq!(n, 16);