Crate reciprocal[][src]



A PartialReciprocal represents an integer (floored) division by a u64 that’s not 0, 1 or u64::MAX.


A Reciprocal represents an integer division by any non-zero u64. It replaces PartialReciprocal’s expression, f(x) = (x + increment) * multiplier >> (64 + shift), where the inner addition is a saturating add by 0 or 1, with g(x) = (x * multiplier + summand) >> (64 + shift), where both the multiplication and additions are in full 128 bit arithmetic. This additional work lets us handle all the cases, including divisions by 1 and by u64::MAX.