Module malachite_base::num::arithmetic::wrapping_neg
source · Expand description
WrappingNeg
and WrappingNegAssign
for
negating a number and wrapping at the boundary of the type.
§wrapping_neg_assign
use malachite_base::num::arithmetic::traits::WrappingNegAssign;
let mut x = 0i8;
x.wrapping_neg_assign();
assert_eq!(x, 0);
let mut x = 100u64;
x.wrapping_neg_assign();
assert_eq!(x, 18446744073709551516);
let mut x = -100i64;
x.wrapping_neg_assign();
assert_eq!(x, 100);
let mut x = -128i8;
x.wrapping_neg_assign();
assert_eq!(x, -128);