FLINT3.7.0-dev

nfloat_add, nfloat_sub, nfloat_mul, nfloat_sqr

Synopsis#include <flint/nfloat.h>
int nfloat_add(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, gr_ctx_t ctx)source
int nfloat_sub(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, gr_ctx_t ctx)source
int nfloat_mul(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, gr_ctx_t ctx)source
int nfloat_sqr(nfloat_ptr res, nfloat_srcptr x, gr_ctx_t ctx)source

Sum, difference, product and square. Without directed rounding the error is less than 2 ulp for the sum and difference (the smaller operand is truncated when it is aligned) and at most 1 ulp for the products (truncation, except that the approximate high product used from three words on can rarely give one ulp less in magnitude); with directed rounding the results are correctly rounded.

The functions dispatch on the number of words to fixed-size kernels: for one and two words the operations are done in registers, the addition through _nfloat_add_1, _nfloat_add_2, ..., _nfloat_add_4 and their subtraction counterparts, and the product with a full 1 \times 1 or 2 \times 2 word product. From three words the product uses the high product flint_mpn_mulhigh_n, whose error is at most a few units of the last word. See Fixed-precision floating point with nfloat.

Guides#

Cite this page

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