FLINT3.7.0-dev

vec1d_round_mul, vec4d_round_mul

Synopsis#include <flint/machine_vectors.h>
vec1d vec1d_round_mul(vec1d a, vec1d b)source
vec4d vec4d_round_mul(vec4d a, vec4d b)source

Returns ab rounded to an integer. With the magic constant (see FLINT_FFT_SMALL_ROUND_USE_NATIVE) this is the nearest integer to the exact product, with ties to even, and requires |ab| \le 2^{51}; a larger product gives a wrong value or a non-integer. With native rounding it is round(mul(a, b)), which rounds twice and has no size condition. AVX2 only.

The magic-constant path computes fmadd(a, b, R) - R with R = 1.5 \cdot 2^{52}. When |ab| \le 2^{51}, the exact sum ab + R lies in [2^{52}, 2^{53}], where consecutive doubles are 1 apart, so the single rounding of the FMA rounds ab to the nearest integer. This avoids vroundpd, which is slow on Intel cores.

Cite this page

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