Module malachite_base::num::arithmetic::wrapping_abs
source · Expand description
WrappingAbs
and WrappingAbsAssign
,
traits for computing the absolute value of a number and wrapping at the boundary of the type.
§wrapping_abs_assign
use malachite_base::num::arithmetic::traits::WrappingAbsAssign;
let mut x = 0i8;
x.wrapping_abs_assign();
assert_eq!(x, 0);
let mut x = 100i64;
x.wrapping_abs_assign();
assert_eq!(x, 100);
let mut x = -100i64;
x.wrapping_abs_assign();
assert_eq!(x, 100);
let mut x = -128i8;
x.wrapping_abs_assign();
assert_eq!(x, -128);