FLINT3.7.0-dev

n_mod2_precomp

Synopsis#include <flint/ulong_extras.h>
ulong n_mod2_precomp(ulong a, ulong n, double ninv)source

Returns a \bmod n with no restrictions on a or n.

For n < 2^{53} and a < n^2, n_mod2_precomp computes the quotient as n_mod_precomp does. Otherwise the top 52 bits of the quotient are correct; the remainder is then multiplied by ninv again to obtain a correction, which may be one out in either direction and is fixed up at the end.

Cite this page

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