FLINT3.7.0-dev

n_mulmod_precomp

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

Returns ab \bmod n. Requires n < 2^{53} and a, b < n.

n_mulmod_precomp computes the product ab in floating point with an error of at most half a place (as defined for n_mod_precomp), and multiplying by ninv gives an approximate quotient within two places of the exact one. Since the quotient is below n < 2^{53}, after truncation the computed integer quotient is at most two above and one below the true quotient; an argument like the one for n_mod_precomp excludes the case of two below. The remainder is corrected accordingly.

Cite this page

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