Module malachite_base::num::arithmetic::overflowing_neg
source · Expand description
OverflowingNeg
and
OverflowingNegAssign
, traits for negating a number and
returning a boolean indicating whether an overflow occurred.
§overflowing_neg_assign
use malachite_base::num::arithmetic::traits::OverflowingNegAssign;
let mut x = 0i8;
assert_eq!(x.overflowing_neg_assign(), false);
assert_eq!(x, 0);
let mut x = 100u64;
assert_eq!(x.overflowing_neg_assign(), true);
assert_eq!(x, 18446744073709551516);
let mut x = -100i64;
assert_eq!(x.overflowing_neg_assign(), false);
assert_eq!(x, 100);
let mut x = -128i8;
assert_eq!(x.overflowing_neg_assign(), true);
assert_eq!(x, -128);