FLINT3.7.0-dev

flint_mpn_bdiv_qr, flint_mpn_bdiv_q

Synopsis#include <flint/mpn_extras.h>
void flint_mpn_bdiv_qr(mp_ptr q, mp_ptr r, mp_srcptr a, mp_size_t an, mp_srcptr b, mp_size_t bn, mp_size_t n)source
void flint_mpn_bdiv_q(mp_ptr q, mp_srcptr a, mp_size_t an, mp_srcptr b, mp_size_t bn, mp_size_t n)source

Hensel division: for odd (b,bn)(b, \mathit{bn}), sets (q,n)(q, n) to the 2-adic quotient with qb≡a(modBn)qb \equiv a \pmod{B^n}. If rr is not NULL (it is NULL for bdiv_q), the remainder (a−qb)/Bn mod Bbn(a - qb)/B^n \bmod B^{\mathit{bn}} is written to (r,bn)(r, \mathit{bn}), so that a≡qb+Bnr(modBn+bn)a \equiv qb + B^n r \pmod{B^{n + \mathit{bn}}}; the division is exact with an nn-limb quotient if and only if r=0r = 0 and aa has no nonzero limbs at positions ≥n+bn\ge n + \mathit{bn}. qq may alias aa. Unlike GMP's mpn_bdiv_qr, the number nn of quotient limbs is a parameter independent of an\mathit{an} and bn\mathit{bn}.

Cite this page

The FLINT team, “flint_mpn_bdiv_qr, flint_mpn_bdiv_q (mpn_extras.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/mpn_extras/flint_mpn_bdiv_qr.html (generated 2026-11-02).