Module malachite_base::num::arithmetic::abs
source · Expand description
Abs
, AbsAssign
, and
UnsignedAbs
, traits for getting the absolute value of a number.
§abs_assign
use malachite_base::num::arithmetic::traits::AbsAssign;
use malachite_base::num::basic::traits::NegativeInfinity;
use malachite_base::num::float::NiceFloat;
let mut x = 0i8;
x.abs_assign();
assert_eq!(x, 0i8);
let mut x = 100i64;
x.abs_assign();
assert_eq!(x, 100i64);
let mut x = -100i64;
x.abs_assign();
assert_eq!(x, 100i64);
let mut x = -0.0;
x.abs_assign();
assert_eq!(NiceFloat(x), NiceFloat(0.0));
let mut x = f64::NEGATIVE_INFINITY;
x.abs_assign();
assert_eq!(NiceFloat(x), NiceFloat(f64::INFINITY));
let mut x = 100.0;
x.abs_assign();
assert_eq!(NiceFloat(x), NiceFloat(100.0));
let mut x = -100.0;
x.abs_assign();
assert_eq!(NiceFloat(x), NiceFloat(100.0));