Module div
Expand description
⚠️ Collection of division algorithms.
Warning. Most functions in this module are currently not considered part of the stable API and may be changed or removed in future minor releases.
All division algorithms also compute the remainder. There is no benefit to splitting the division and remainder into separate functions, since the remainder is always computed as part of the division algorithm.
These functions are adapted from algorithms in MG10 and K97.
Functions§
- div
- ⚠️ Division with remainder.
- div_2x1
- ⚠️ Computes the quotient and remainder of a
u128
divided by au64
. - div_
2x1_ mg10 - ⚠️ Computes the quotient and remainder of a
u128
divided by au64
. - div_
2x1_ ref - div_3x2
- ⚠️ Computes the quotient of a 192 bits divided by a normalized u128.
- div_
3x2_ mg10 - ⚠️ Computes the quotient of a 192 bits divided by a normalized u128.
- div_
3x2_ ref - TODO: This implementation is off by one.
- div_nx1
- ⚠️ Compute single limb division.
- div_nx2
- ⚠️ Compute double limb division.
- div_
nx1_ normalized - ⚠️ Compute single limb normalized division.
- div_
nx2_ normalized - ⚠️ Compute double limb normalized division.
- div_nxm
- ⚠️ In-place Knuth long division with implicit normalization and reciprocals.
- div_
nxm_ normalized - ⚠️ In-place Knuth normalized long division with reciprocals.
- reciprocal
- ⚠️ Computes $\floor{\frac{2^{128} - 1}{\mathsf{d}}} - 2^{64}$.
- reciprocal_
2 - ⚠️ Computes $\floor{\frac{2^{192} - 1}{\mathsf{d}}} - 2^{64}$.
- reciprocal_
2_ mg10 - ⚠️ Computes $\floor{\frac{2^{192} - 1}{\mathsf{d}}} - 2^{64}$.
- reciprocal_
mg10 - ⚠️ Computes $\floor{\frac{2^{128} - 1}{\mathsf{d}}} - 2^{64}$.
- reciprocal_
ref - ⚠️ Computes $\floor{\frac{2^{128} - 1}{\mathtt{d}}} - 2^{64}$.