Expand description

DivExact and DivExactAssign, traits for dividing two numbers when it’s known that the division is exact.

div_exact

use malachite_base::num::arithmetic::traits::DivExact;

// 123 * 456 = 56088
assert_eq!(56088u32.div_exact(456), 123);

// -123 * -456 = 56088
assert_eq!(56088i64.div_exact(-456), -123);

div_exact_assign

use malachite_base::num::arithmetic::traits::DivExactAssign;

// 123 * 456 = 56088
let mut x = 56088u32;
x.div_exact_assign(456);
assert_eq!(x, 123);

// -123 * -456 = 56088
let mut x = 56088i64;
x.div_exact_assign(-456);
assert_eq!(x, -123);