FLINT3.7.0-dev

decfloat_get_fmpz, decfloat_get_fmpq, decfloat_get_si, decfloat_get_ui, decfloat_get_d, decfloat_get_fmpz_10exp_fmpz, decfloat_get_arf, decfloat_get_arb, decfloat_get_fmpz_fixed_si

Synopsis#include <flint/decimal.h>
int decfloat_get_fmpz(fmpz_t res, const decfloat_t x, gr_ctx_t ctx)source
int decfloat_get_fmpq(fmpq_t res, const decfloat_t x, gr_ctx_t ctx)source
int decfloat_get_si(slong * res, const decfloat_t x, gr_ctx_t ctx)source
int decfloat_get_ui(ulong * res, const decfloat_t x, gr_ctx_t ctx)source
int decfloat_get_d(double * res, const decfloat_t x, gr_ctx_t ctx)source
int decfloat_get_fmpz_10exp_fmpz(fmpz_t m, fmpz_t e, const decfloat_t x, gr_ctx_t ctx)source
int decfloat_get_arf(arf_t res, const decfloat_t x, slong prec_bits, int rnd, gr_ctx_t ctx)source
int decfloat_get_arb(arb_t res, const decfloat_t x, slong prec_bits, gr_ctx_t ctx)source
int decfloat_get_fmpz_fixed_si(fmpz_t res, const decfloat_t x, slong e, int rnd, gr_ctx_t ctx)source

Conversions out. The integer conversions return GR_DOMAIN for non-integers and GR_UNABLE for integers with more than DECIMAL_CONV_DIGITS_LIMIT digits. The decomposition x = m \cdot 10^e is returned with m not divisible by 10. decfloat_get_fmpz_fixed_si computes x / 10^e rounded to an integer in the rounding mode rnd.

Doubles are correctly rounded to nearest; values outside the normal range of doubles give GR_UNABLE. Conversion to arf is correctly rounded to prec_bits bits in the arf rounding mode rnd (ARF_PREC_EXACT is allowed and succeeds when the value is a dyadic rational), and conversion to arb gives an enclosure with prec_bits bits. The latter is exact for a dyadic value whose exact conversion is no more expensive than the target precision; otherwise only the leading O(\mathrm{prec\_bits}) digits of the mantissa are used (with an error bound for the rest), so that the cost is independent of the length of the mantissa and of the size of the exponent.

Cite this page

The FLINT team, “decfloat_get_fmpz, decfloat_get_fmpq, decfloat_get_si, decfloat_get_ui, decfloat_get_d, decfloat_get_fmpz_10exp_fmpz, decfloat_get_arf, decfloat_get_arb, decfloat_get_fmpz_fixed_si (decimal.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/decimal/decfloat_get_fmpz.html (generated 2026-10-20).