Module malachite_base::num::arithmetic::mod_power_of_2_add
source · Expand description
ModPowerOf2Add
and
ModPowerOf2AddAssign
, traits for adding two numbers modulo
$2^k$.
§mod_power_of_2_add
use malachite_base::num::arithmetic::traits::ModPowerOf2Add;
assert_eq!(0u8.mod_power_of_2_add(2, 5), 2);
assert_eq!(10u32.mod_power_of_2_add(14, 4), 8);
§mod_power_of_2_add_assign
use malachite_base::num::arithmetic::traits::ModPowerOf2AddAssign;
let mut n = 0u8;
n.mod_power_of_2_add_assign(2, 5);
assert_eq!(n, 2);
let mut n = 10u32;
n.mod_power_of_2_add_assign(14, 4);
assert_eq!(n, 8);