Module malachite_base::num::arithmetic::saturating_pow
source · Expand description
SaturatingPow
and
SaturatingPowAssign
, traits for raising a number to a power and
saturating at numeric bounds instead of overflowing.
§saturating_pow_assign
use malachite_base::num::arithmetic::traits::SaturatingPowAssign;
let mut x = 3u8;
x.saturating_pow_assign(3);
assert_eq!(x, 27);
let mut x = -10i32;
x.saturating_pow_assign(9);
assert_eq!(x, -1000000000);
let mut x = -10i16;
x.saturating_pow_assign(9);
assert_eq!(x, -32768);