Set the default rounding mode to rnd. The default rounding mode is to nearest initially.
Round x according to rnd with precision prec, which must be an integer between
MPFR_PREC_MIN
andMPFR_PREC_MAX
(otherwise the behavior is undefined). If prec is greater or equal to the precision of x, then new space is allocated for the significand, and it is filled with zeros. Otherwise, the significand is rounded to precision prec with the given direction. In both cases, the precision of x is changed to prec.
[This function is obsolete. Please use
mpfr_prec_round
instead.]
Assuming b is an approximation of an unknown number x in the direction rnd1 with error at most two to the power E(b)-err where E(b) is the exponent of b, return a non-zero value if one is able to round correctly x to precision prec with the direction rnd2, and 0 otherwise (including for NaN and Inf). This function does not modify its arguments.
Note: if one wants to also determine the correct ternary value when rounding b to precision prec, a useful trick is the following:
if (mpfr_can_round (b, err, rnd1, GMP_RNDZ, prec + (rnd2 == GMP_RNDN))) ...Indeed, if rnd2 isGMP_RNDN
, this will check if one can round to prec+1 bits with a directed rounding: if so, one can surely round to nearest to prec bits, and in addition one can determine the correct ternary value, which would not be the case when b is near from a value exactly representable on prec bits.