Module malachite_base::num::arithmetic::mod_power_of_2_shr
source · Expand description
ModPowerOf2Shr
and
ModPowerOf2ShrAssign
, traits for right-shifting a number
modulo $2^k$.
§mod_power_of_2_shr
use malachite_base::num::arithmetic::traits::ModPowerOf2Shr;
assert_eq!(10u8.mod_power_of_2_shr(2i64, 4), 2);
assert_eq!(12u32.mod_power_of_2_shr(-2i8, 5), 16);
§mod_power_of_2_shr_assign
use malachite_base::num::arithmetic::traits::ModPowerOf2ShrAssign;
let mut n = 10u8;
n.mod_power_of_2_shr_assign(2i64, 4);
assert_eq!(n, 2);
let mut n = 12u32;
n.mod_power_of_2_shr_assign(-2i8, 5);
assert_eq!(n, 16);