Module malachite_nz::natural::arithmetic::mod_power_of_2_shr
source · [−]Expand description
Implementations of ModPowerOf2Shr
and ModPowerOf2ShrAssign
,
traits for right-shifting a number modulo $2^k$.
mod_power_of_2_shr
extern crate malachite_base;
use malachite_base::num::arithmetic::traits::ModPowerOf2Shr;
use malachite_nz::natural::Natural;
assert_eq!(Natural::from(123u32).mod_power_of_2_shr(-5i16, 8), 96);
assert_eq!(Natural::from(123u32).mod_power_of_2_shr(-100i64, 80), 0);
assert_eq!(Natural::from(123u32).mod_power_of_2_shr(2i8, 8), 30);
assert_eq!((&Natural::from(123u32)).mod_power_of_2_shr(-5i16, 8), 96);
assert_eq!((&Natural::from(123u32)).mod_power_of_2_shr(-100i64, 80), 0);
assert_eq!((&Natural::from(123u32)).mod_power_of_2_shr(2i8, 8), 30);
mod_power_of_2_shr_assign
extern crate malachite_base;
use malachite_base::num::arithmetic::traits::ModPowerOf2ShrAssign;
use malachite_nz::natural::Natural;
let mut n = Natural::from(123u32);
n.mod_power_of_2_shr_assign(-5i16, 8);
assert_eq!(n, 96);
let mut n = Natural::from(123u32);
n.mod_power_of_2_shr_assign(-100i64, 80);
assert_eq!(n, 0);
let mut n = Natural::from(123u32);
n.mod_power_of_2_shr_assign(2i8, 8);
assert_eq!(n, 30);