pub trait TypedDiv<K: IsInteger> {
type Output: IsInteger;
type Remainder: IsInteger;
}
Expand description
Returns the Quotient of H/K for H: Div<K, Output: …>
Note about implementation detail: This is an expanded version of long division - it takes O(1) steps but the constant is quite big unfortunately (to be precise its 32 multiplications plus a negligible amount of addition and subtraction and other stuff) If there were many divisions, the compile time increases quite a bit
Example
// (This doc test takes about 5 seconds to complete on my computer)
use const_arithmetic::*;
let a = parse_integer!(25);
let b = parse_integer!(4);
let quotient = parse_integer!(6);
let modulus = parse_integer!(1);
// This verifies that 25/4 = 6 ... 1
fn example<P, Q, R, S>(_p: P, _q: Q, _r: R, _s: S) where
P: IsInteger,
Q: IsInteger,
R: IsInteger,
S: IsInteger,
P: TypedDiv<Q, Output = R, Remainder = S>
{}
example(a, b, quotient, modulus);