FLINT3.7.0-dev

_arf_mpn_div, _arf_mpn_inv, _arf_mpn_sqrt, _arf_mpn_rsqrt

Synopsis#include <flint/arf.h>
int _arf_mpn_div(nn_ptr z, slong * zexp, nn_srcptr x, slong xn, nn_srcptr y, slong yn, slong prec, arf_rnd_t rnd)source
int _arf_mpn_inv(nn_ptr z, slong * zexp, nn_srcptr y, slong yn, slong prec, arf_rnd_t rnd)source
int _arf_mpn_sqrt(nn_ptr z, slong * zexp, nn_srcptr x, slong xn, int t, slong prec, arf_rnd_t rnd)source
int _arf_mpn_rsqrt(nn_ptr z, slong * zexp, nn_srcptr x, slong xn, int t, slong prec, arf_rnd_t rnd)source

The quotient x/yx / y, the reciprocal 1/y1 / y, the square root of xx and its reciprocal, correctly rounded to prec bits in the sign-free mode rnd into {z,rn}\{z, \mathit{rn}\}, returning the inexact flag, with *zexp the correction to the natural exponent: ex−eye_x - e_y for the quotient (the correction 0 or 1), −ey-e_y for the reciprocal (1 or 2), and for the roots of x=A⋅2ex = A \cdot 2^e with t=e mod 2t = e \bmod 2 given, (e+t)/2(e + t) / 2 for x\sqrt{x} and (1−t)−(e−t)/2(1 - t) - (e - t) / 2 for 1/x1 / \sqrt{x} (the corrections 0 or 1).

The output may alias an operand. Zero low limbs of the mantissas (nfloat pads its mantissas to a fixed length) are stripped first, so that integers and other short operands take the fast paths.

Small sizes are exact and in registers (mpn_extras/fp_small.h, with arf/mpn_small.h for callers with fixed small sizes): a quotient of one limb from one-limb operands by one 2/12/1 division, a quotient of up to two limbs from operands of up to two (divisor: three) limbs by two or three 3/23/2 divisions, each giving the floor with the remainder, from which the rounding is decided (the remainder encoded as the limb below the floor: its top bit the half bit, a low bit the sticky bit); a divisor of a single limb at any size by a chain of 2/12/1 divisions (flint_mpn_divrem_1_preinv, GMP's mpn_divrem_1 from eight limbs). The one-limb square root is the exact integer root of the two-limb radicand (_flint_mpn_isqrt_2_rem, the remainder deciding the half bit); the two-limb roots and the one-limb reciprocal root come from the three- resp. two-limb register kernels, certified when their guard limb lies away from the rounding boundaries.

Longer quotients and reciprocal roots use the guard-limb kernels of mpn_extras (flint_mpn_divhigh, flint_mpn_rsqrthigh, see Floating-point quotients and roots): rn+1\mathit{rn} + 1 limbs with the top bit set, the lowest a guard limb within a small bound of the exact value in either direction, certified by _arf_mpn_round_guarded, with the exact floor of the same quantity (the _exact variants, with an inexact flag) as the fallback. Longer square roots are exact integer roots of the mantissa padded to 2 rn2 \, \mathit{rn} limbs (flint_mpn_sqrthigh_exact; for rounding to nearest at a limb boundary the variant with the half bit up to 24 limbs, the guard-limb root beyond), which is cheaper than the guard limb below the Newton range. A divisor that is a power of two shifts; a root of a power of two with an odd exponent is a power of two.

Cite this page

The FLINT team, “_arf_mpn_div, _arf_mpn_inv, _arf_mpn_sqrt, _arf_mpn_rsqrt (arf.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/arf/_arf_mpn_div.html (generated 2026-11-20).