_arf_mpn_round_guarded
#include <flint/arf.h>int _arf_mpn_round_guarded(nn_ptr res, slong * exp, nn_srcptr a, slong n, ulong g, int e, slong prec, arf_rnd_t rnd, int side)sourceGiven the normalised limbs a and the limb g below them, which together approximate a value to within ulps of g (in either direction for side = 0, strictly above the approximation for side = 1, strictly below it for side = ), rounds the value to bits when the guard limb certifies the rounding: writes the limbs to res (which may be a, or lie below it in the same buffer), sets exp to the change of the exponent (, 0 or 1) and returns 1, the value being inexact. Returns when the window does not certify the rounding; the exact value must then be computed.
With the approximation within ulps of the exact value and discarded bits, the bits of g being neither all zero nor all ones gives , so that lies strictly between the same rounding boundaries as (the truncation point and the half point) and is not exact; the rounding of is then the rounding of in every mode [AJ2025]. The check fails with probability about . With the direction of the error known, only the boundary in that direction matters: all zeros will do for a value above the approximation (which then rounds like the approximation with sticky bits), all ones for one below; and a value just below an approximation that is exact at prec bits rounds to it, or to the value below it when rounding toward zero.
References#
- [AJ2025] A. Ahlbäck and F. Johansson. Fast basecases for arbitrary-size multiplication. 2025 IEEE 32nd Symposium on Computer Arithmetic (ARITH 2025), 53–60. https://doi.org/10.1109/ARITH64983.2025.00018 (preprint: https://hal.science/hal-04861755)
The FLINT team, “_arf_mpn_round_guarded (arf.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/arf/_arf_mpn_round_guarded.html (generated 2026-11-20).
@misc{flint-doc-arf-arf-mpn-round-guarded,
author = {{The FLINT team}},
title = {{\_arf\_mpn\_round\_guarded (arf.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/arf/_arf_mpn_round_guarded.html},
note = {Generated 2026-11-20}
}