Module malachite_base::num::arithmetic::overflowing_abs
source · Expand description
OverflowingAbs
and
OverflowingAbsAssign
, traits for taking the absolute value of
a number and returning a boolean indicating whether an overflow occurred.
§overflowing_abs_assign
use malachite_base::num::arithmetic::traits::OverflowingAbsAssign;
let mut x = 0i8;
assert_eq!(x.overflowing_abs_assign(), false);
assert_eq!(x, 0);
let mut x = 100i64;
assert_eq!(x.overflowing_abs_assign(), false);
assert_eq!(x, 100);
let mut x = -100i64;
assert_eq!(x.overflowing_abs_assign(), false);
assert_eq!(x, 100);
let mut x = -128i8;
assert_eq!(x.overflowing_abs_assign(), true);
assert_eq!(x, -128);