Module malachite_base::num::arithmetic::checked_square

source ·
Expand description

CheckedSquare, a trait for squaring a number and checking whether the result is representable.

§checked_square

use malachite_base::num::arithmetic::traits::CheckedSquare;

assert_eq!(3u8.checked_square(), Some(9));
assert_eq!((-1000i32).checked_square(), Some(1000000));
assert_eq!((1000u16).checked_square(), None);