FLINT3.7.0-dev

_nmod_mul_halflimb

Synopsis#include <flint/nmod.h>
ulong _nmod_mul_halflimb(ulong a, ulong b, nmod_t mod)source

Returns ab mod nab \bmod n for reduced operands. Requires n≤2FLINT_BITS/2n \le 2^{\mathtt{FLINT\_BITS} / 2}, which NMOD_IS_HALFLIMB tests; for larger nn the result is wrong. The product abab then fits in one word, and is reduced with the one-word Barrett step of NMOD_RED (Low-level macros), which is shorter than the two-word reduction of nmod_mul. To use it in a loop, test the modulus once and write two loops, one with _nmod_mul_halflimb and one with nmod_mul, rather than testing it at each product.

Guides#

Cite this page

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