decimal_ctx_set_prec, decimal_ctx_set_rnd, decimal_ctx_set_rnd_im, decimal_ctx_set_rad_prec, decimal_ctx_set_exp_limits, decimal_ctx_set_flags
#include <flint/decimal.h>Changes the default precision, the default rounding mode, the radius precision (clamped to where R = DECMAG_MAX_PREC is 9 on a 64-bit machine and 4 on a 32-bit machine), the exponent limits and the flags of a context. Exponent limits apply to the scientific exponent of a number , ; WORD_MIN and WORD_MAX denote the absence of a limit. All settings can be changed at any time; see Operands and results.
In a complex floating-point context, real parts are rounded in the mode set by decimal_ctx_set_rnd, which also resets the mode for imaginary parts, and decimal_ctx_set_rnd_im subsequently changes the mode for imaginary parts alone. The imaginary rounding mode is ignored in the other contexts.
Through the generics interface, gr_ctx_has_real_prec is true and gr_ctx_set_real_prec and gr_ctx_get_real_prec are supported with the precision measured in bits: setting bits selects digits, and a context with digits reports bits (directed rounding to digits has a relative error up to , slightly more than that of bits). This lets generic algorithms that take a precision in bits (series expansions, linear algebra with adaptive precision) work with decimal contexts. Since they assume radix-2 semantics, their results need not be what they would be for binary types, but they remain correct, since all decimal operations return correctly rounded results or rigorous enclosures.
Guides#
The FLINT team, “decimal_ctx_set_prec, decimal_ctx_set_rnd, decimal_ctx_set_rnd_im, decimal_ctx_set_rad_prec, decimal_ctx_set_exp_limits, decimal_ctx_set_flags (decimal.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/decimal/decimal_ctx_set_prec.html (generated 2026-11-02).
@misc{flint-doc-decimal-decimal-ctx-set-prec,
author = {{The FLINT team}},
title = {{decimal\_ctx\_set\_prec, decimal\_ctx\_set\_rnd, decimal\_ctx\_set\_rnd\_im, decimal\_ctx\_set\_rad\_prec, decimal\_ctx\_set\_exp\_limits, decimal\_ctx\_set\_flags (decimal.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/decimal/decimal_ctx_set_prec.html},
note = {Generated 2026-11-02}
}