FLINT3.7.0-dev

n_sqrt, n_sqrtrem

Synopsis#include <flint/ulong_extras.h>
ulong n_sqrt(ulong a)source
ulong n_sqrtrem(ulong * r, ulong a)source

Returns \lfloor \sqrt a \rfloor. n_sqrtrem also sets *r to a - \lfloor \sqrt a \rfloor^2.

n_sqrt computes the square root in IEEE double precision. If a is one below a square the rounding may be up, giving a result one too large, which is then corrected; care is taken that squaring the too-large value does not overflow.

Cite this page

The FLINT team, “n_sqrt, n_sqrtrem (ulong_extras.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/ulong_extras/n_sqrt.html (generated 2026-10-20).