Module malachite_base::num::arithmetic::abs_diff
source · Expand description
AbsDiff
and AbsDiffAssign
, traits for getting
the absolute value of the difference between two numbers.
§abs_diff
assert_eq!(10u8.abs_diff(20u8), 10u8);
assert_eq!(10i8.abs_diff(-10i8), 20u8);
§abs_diff_assign
use malachite_base::num::arithmetic::traits::AbsDiffAssign;
let mut x = 10u8;
x.abs_diff_assign(20u8);
assert_eq!(x, 10);