Module malachite_base::num::arithmetic::mod_power_of_2_neg
source · Expand description
ModPowerOf2Neg
and
ModPowerOf2NegAssign
, traits for negating a number modulo
$2^k$.
§mod_power_of_2_neg
use malachite_base::num::arithmetic::traits::ModPowerOf2Neg;
assert_eq!(0u8.mod_power_of_2_neg(5), 0);
assert_eq!(10u32.mod_power_of_2_neg(4), 6);
assert_eq!(100u16.mod_power_of_2_neg(8), 156);
§mod_power_of_2_neg_assign
use malachite_base::num::arithmetic::traits::ModPowerOf2NegAssign;
let mut n = 0u8;
n.mod_power_of_2_neg_assign(5);
assert_eq!(n, 0);
let mut n = 10u32;
n.mod_power_of_2_neg_assign(4);
assert_eq!(n, 6);
let mut n = 100u16;
n.mod_power_of_2_neg_assign(8);
assert_eq!(n, 156);