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.

For one and two words, the mantissas are divided by an inlined 2/1 division or two 3/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 gives the exact rounding information. These use 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) use a chain of 2/1 divisions, O(n). Otherwise a schoolbook approximate division (_flint_mpn_divapprox_basecase_preinv1) computes the quotient or the quotient plus one at the target precision. With directed rounding, one guard word is computed and the truncation is certified unless the guard word is 0 or 1, in which case (for example for exact quotients) the exact quotient and remainder are computed.

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-10-20).