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§
- checked_
reciprocal - Checked version of
reciprocal_mg10. - checked_
reciprocal_ 2 - Checked version of
reciprocal_2_mg10. ReturnsNoneif $\mathsf{d} < 2^{127}$. - div
- ⚠️ Division with remainder.
- div_1x1
- ⚠️ Compute single limb division.
- div_2x1
- ⚠️ Computes the quotient and remainder of a
u128divided by au64. - div_
2x1_ mg10 - ⚠️ Computes the quotient and remainder of a
u128divided by au64. - div_
2x1_ ref - ⚠️ Reference implementation for
div_2x1. - 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 - ⚠️ Reference implementation for
div_3x2. - 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}$.