FLINT3.7.0-dev

nfloat_inv, nfloat_div, nfloat_div_ui, nfloat_div_si

Synopsis#include <flint/nfloat.h>
int nfloat_inv(nfloat_ptr res, nfloat_srcptr x, gr_ctx_t ctx)source
int nfloat_div(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, gr_ctx_t ctx)source
int nfloat_div_ui(nfloat_ptr res, nfloat_srcptr x, ulong y, gr_ctx_t ctx)source
int nfloat_div_si(nfloat_ptr res, nfloat_srcptr x, slong y, gr_ctx_t ctx)source

Inverse and quotients. Without directed rounding, the result is the quotient truncated toward zero or, for divisors of three or more nonzero words, possibly one ulp larger in magnitude (an error of less than 1 ulp); div_ui and div_si are always truncated. With directed rounding, the result is the correctly rounded floor or ceiling of the exact quotient. Division by zero gives NaN, so it returns GR_UNABLE unless NaN is allowed.

On the quotient kernels of Limb-array kernels: without directed rounding _arf_mpn_div_approx, with directed rounding _arf_mpn_div in the mode toward or away from zero that the sign and the context's direction call for. The kernels strip the zero low words of the mantissas and dispatch on the sizes: for one and two words, an inlined 2/12/1 division or two 3/23/2 divisions with the dividend shifted right by one bit beforehand when it is larger than the divisor, so that the quotient comes out normalised, the remainder giving the exact rounding information (hardware division where it is fast, FLINT_PREINVERT_LIMB_USE_NATIVE, and a precomputed inverse otherwise [GraMol2010]); divisors with a single nonzero word (such as small integers) by a chain of 2/12/1 divisions, O(n)O(n), exactly; divisors of two words by the exact register-based division. Otherwise, without directed rounding, a schoolbook approximate division (_flint_mpn_divapprox_basecase_preinv1) computes the quotient or the quotient plus one at the target precision, and with directed rounding the shared flint_mpn_divhigh computes one guard word and the truncation is certified unless the guard word is within the error bound of 0 or B−1B - 1, in which case (for example for exact quotients) the exact quotient and remainder are computed (flint_mpn_divhigh_exact); see Floating-point quotients and roots. The vector functions keep their own paths for a fixed divisor (a precomputed inverse of one or two words, the approximate reciprocal of a longer one).

Guides#

References#

Cite this page

The FLINT team, “nfloat_inv, nfloat_div, nfloat_div_ui, nfloat_div_si (nfloat.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/nfloat/nfloat_inv.html (generated 2026-11-20).