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 [1, R] 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 E of a number x, 10^E \le |x| < 10^{E+1}; 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 p bits selects \lceil p \log_{10} 2 \rceil digits, and a context with d digits reports \lfloor d \log_2 10 \rfloor - 1 bits (directed rounding to d digits has a relative error up to 10^{1-d}, slightly more than that of d \log_2 10 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-10-20).
@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-10-20}
}