Module malachite_base::num::arithmetic::square
source · Expand description
Square
and SquareAssign
, traits for squaring a
number.
§square
use malachite_base::num::arithmetic::traits::Square;
assert_eq!(3u8.square(), 9);
assert_eq!((-1000i32).square(), 1000000);
assert_eq!(1.5f32.square(), 2.25);
§square_assign
use malachite_base::num::arithmetic::traits::SquareAssign;
let mut x = 3u8;
x.square_assign();
assert_eq!(x, 9);
let mut x = -1000i32;
x.square_assign();
assert_eq!(x, 1000000);
let mut x = 1.5f32;
x.square_assign();
assert_eq!(x, 2.25);