flint_mpn_divexact
#include <flint/mpn_extras.h>void flint_mpn_divexact(mp_ptr q, mp_srcptr a, mp_size_t an, mp_srcptr b, mp_size_t bn)sourceExact division: sets (q, \mathit{an} - \mathit{bn} + 1) to a/b, assuming that b divides a (otherwise the result is meaningless).
Single-limb divisors are handled by mpn_divexact_1. Otherwise the division is done 2-adically: writing b = 2^v B^k b' with b' odd, the quotient is (a / (2^v B^k))\, b'^{-1} \bmod B^m, where m is the number of quotient limbs (\mathit{an} - \mathit{bn} + 1, or one less when the top limb of a is below that of b). With d = \min(\mathit{bn}, m) significant divisor limbs, d \le 7 uses register-resident code specialised for each d, with the shift done on the fly and the limb inverse b'^{-1} \bmod B computed inline. Larger d use ports of GMP's schoolbook and divide and conquer Hensel division (mpn_sbpi1_bdiv_q, and mpn_dcpi1_bdiv_q from FLINT_MPN_DC_BDIV_Q_CUTOFF limbs) with FLINT's multiplication, and the Newton iteration flint_mpn_bdiv_q from d \ge FLINT_MPN_DIVEXACT_NEWTON_CUTOFF, or already from \mathit{bn} \ge FLINT_MPN_DIVEXACT_UNBALANCED_CUTOFF when m \ge 4 \mathit{bn}.
The FLINT team, “flint_mpn_divexact (mpn_extras.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/mpn_extras/flint_mpn_divexact.html (generated 2026-10-20).
@misc{flint-doc-mpn-extras-flint-mpn-divexact,
author = {{The FLINT team}},
title = {{flint\_mpn\_divexact (mpn\_extras.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/mpn_extras/flint_mpn_divexact.html},
note = {Generated 2026-10-20}
}