Expand description

WrappingSquare and WrappingSquareAssign, traits for squaring a number and wrapping at the boundary of the type.

wrapping_square

use malachite_base::num::arithmetic::traits::WrappingSquare;

assert_eq!(3u8.wrapping_square(), 9);
assert_eq!((-1000i32).wrapping_square(), 1000000);
assert_eq!(1000u16.wrapping_square(), 16960);

wrapping_square_assign

use malachite_base::num::arithmetic::traits::WrappingSquareAssign;

let mut x = 3u8;
x.wrapping_square_assign();
assert_eq!(x, 9);

let mut x = -1000i32;
x.wrapping_square_assign();
assert_eq!(x, 1000000);

let mut x = 1000u16;
x.wrapping_square_assign();
assert_eq!(x, 16960);