nfloat_add, nfloat_sub, nfloat_mul, nfloat_sqr
#include <flint/nfloat.h>int nfloat_add(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, gr_ctx_t ctx)sourceint nfloat_sub(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, gr_ctx_t ctx)sourceint nfloat_mul(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, gr_ctx_t ctx)sourceint nfloat_sqr(nfloat_ptr res, nfloat_srcptr x, gr_ctx_t ctx)sourceSum, 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#
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).
@misc{flint-doc-nfloat-nfloat-add,
author = {{The FLINT team}},
title = {{nfloat\_add, nfloat\_sub, nfloat\_mul, nfloat\_sqr (nfloat.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/nfloat/nfloat_add.html},
note = {Generated 2026-10-20}
}