Module malachite_base::num::arithmetic::mod_power_of_2_shl
source · Expand description
ModPowerOf2Shl
and
ModPowerOf2ShlAssign
, traits for left-shifting a number modulo
$2^k$.
§mod_power_of_2_shl
use malachite_base::num::arithmetic::traits::ModPowerOf2Shl;
assert_eq!(12u32.mod_power_of_2_shl(2u8, 5), 16);
assert_eq!(10u8.mod_power_of_2_shl(100u64, 4), 0);
assert_eq!(12u32.mod_power_of_2_shl(2i8, 5), 16);
assert_eq!(10u8.mod_power_of_2_shl(-2i64, 4), 2);
§mod_power_of_2_shl_assign
use malachite_base::num::arithmetic::traits::ModPowerOf2ShlAssign;
let mut n = 12u32;
n.mod_power_of_2_shl_assign(2u8, 5);
assert_eq!(n, 16);
let mut n = 10u8;
n.mod_power_of_2_shl_assign(100u64, 4);
assert_eq!(n, 0);
let mut n = 12u32;
n.mod_power_of_2_shl_assign(2i8, 5);
assert_eq!(n, 16);
let mut n = 10u8;
n.mod_power_of_2_shl_assign(-2i64, 4);
assert_eq!(n, 2);