FLINT3.7.0-dev

mp_real_unique_integer

Synopsis#include <flint/mp_real.h>
int mp_real_unique_integer(mp_real_t res, const mp_real_t x)source

If the ball x contains exactly one integer, set res to that integer (exactly) and return 1; otherwise return 0 and leave res unchanged. res may alias x, in which case no reallocation takes place.

This is arb_get_unique_fmpz with the result kept as an mp_real_t, free of the size limits of fmpz_t. With a fractional part of f limbs and a radius below one ulp, the candidates follow from the carry of the fraction plus the radius and the borrow of the fraction minus the radius, decided by scanning the fraction from its top limb until a limb is neither all zeros nor all ones; the integer part is then moved down (and incremented if needed).

Guides#

Cite this page

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