nfloat_sqrt, nfloat_rsqrt
#include <flint/nfloat.h>int nfloat_sqrt(nfloat_ptr res, nfloat_srcptr x, gr_ctx_t ctx)sourceint nfloat_rsqrt(nfloat_ptr res, nfloat_srcptr x, gr_ctx_t ctx)sourceSquare root and reciprocal square root. The square root is correctly rounded in every mode (truncated toward zero by default); the reciprocal square root has an error of less than ulp by default and is correctly rounded with directed rounding. Negative arguments give NaN.
On the root kernels of Limb-array kernels (_arf_mpn_sqrt_approx and _arf_mpn_rsqrt_approx without directed rounding, _arf_mpn_sqrt and _arf_mpn_rsqrt with it). The square root is the truncated integer square root of the mantissa padded to words, with an exactness flag (flint_mpn_sqrthigh_exact, see Floating-point quotients and roots). At one word on 64-bit machines it is computed in registers: a double-precision root (within of the exact root), one correction from the exact residual evaluated in double precision, and a final exact residual, which gives the floor and the exactness flag. At two words the root is first approximated at three words from the two-word reciprocal square root below and one Newton step with the exact residual, which certifies the truncation unless the guard word is within 3 units of 0 or .
The reciprocal square root refines a double-precision approximation by one Newton step at 128 bits (one word), or a two-word starting value by one Newton step with the residual evaluated exactly from the six-word product of the mantissa and the square of the starting value (two words). For words, the shared flint_mpn_rsqrthigh yields the result with one guard word, within FLINT_MPN_RSQRTHIGH_GUARD_ERR_BOUND units of the guard word. With directed rounding the truncation is certified from these error bounds, and in the rare uncertain cases the exact result is computed (flint_mpn_rsqrthigh_exact) for or , in terms of the -word mantissa and the word size .
Guides#
The FLINT team, “nfloat_sqrt, nfloat_rsqrt (nfloat.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/nfloat/nfloat_sqrt.html (generated 2026-11-20).
@misc{flint-doc-nfloat-nfloat-sqrt,
author = {{The FLINT team}},
title = {{nfloat\_sqrt, nfloat\_rsqrt (nfloat.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/nfloat/nfloat_sqrt.html},
note = {Generated 2026-11-20}
}