Module malachite_base::num::arithmetic::arithmetic_checked_shr
source · Expand description
ArithmeticCheckedShr
, a trait for right-shifting a number and
checking whether the result is representable.
§arithmetic_checked_shr
use malachite_base::num::arithmetic::traits::ArithmeticCheckedShr;
assert_eq!(100u8.arithmetic_checked_shr(3), Some(12u8));
assert_eq!(100u8.arithmetic_checked_shr(100), Some(0u8));
assert_eq!(3u8.arithmetic_checked_shr(-6), Some(192u8));
assert_eq!(3u8.arithmetic_checked_shr(-7), None);
assert_eq!(3u8.arithmetic_checked_shr(-100), None);
assert_eq!(0u8.arithmetic_checked_shr(-100), Some(0u8));
assert_eq!(100i8.arithmetic_checked_shr(3), Some(12i8));
assert_eq!((-100i8).arithmetic_checked_shr(3), Some(-13i8));
assert_eq!(100i8.arithmetic_checked_shr(100), Some(0i8));
assert_eq!((-100i8).arithmetic_checked_shr(100), Some(-1i8));
assert_eq!(3i8.arithmetic_checked_shr(-5), Some(96i8));
assert_eq!(3i8.arithmetic_checked_shr(-6), None);
assert_eq!((-3i8).arithmetic_checked_shr(-5), Some(-96i8));
assert_eq!((-3i8).arithmetic_checked_shr(-6), None);
assert_eq!(3i8.arithmetic_checked_shr(-100), None);
assert_eq!((-3i8).arithmetic_checked_shr(-100), None);
assert_eq!(0i8.arithmetic_checked_shr(-100), Some(0i8));