Next: Rounding Related Functions, Previous: Formatted Output Functions, Up: MPFR Interface
Set rop to op rounded to an integer.
mpfr_rint
rounds to the nearest representable integer in the given rounding mode,mpfr_ceil
rounds to the next higher or equal representable integer,mpfr_floor
to the next lower or equal representable integer,mpfr_round
to the nearest representable integer, rounding halfway cases away from zero, andmpfr_trunc
to the next representable integer toward zero.The returned value is zero when the result is exact, positive when it is greater than the original value of op, and negative when it is smaller. More precisely, the returned value is 0 when op is an integer representable in rop, 1 or −1 when op is an integer that is not representable in rop, 2 or −2 when op is not an integer.
Note that
mpfr_round
is different frommpfr_rint
called with the rounding to nearest mode (where halfway cases are rounded to an even integer or significand). Note also that no double rounding is performed; for instance, 4.5 (100.1 in binary) is rounded bympfr_round
to 4 (100 in binary) in 2-bit precision, thoughround(4.5)
is equal to 5 and 5 (101 in binary) is rounded to 6 (110 in binary) in 2-bit precision.
Set rop to op rounded to an integer.
mpfr_rint_ceil
rounds to the next higher or equal integer,mpfr_rint_floor
to the next lower or equal integer,mpfr_rint_round
to the nearest integer, rounding halfway cases away from zero, andmpfr_rint_trunc
to the next integer toward zero. If the result is not representable, it is rounded in the direction rnd. The returned value is the ternary value associated with the considered round-to-integer function (regarded in the same way as any other mathematical function).
Set rop to the fractional part of op, having the same sign as op, rounded in the direction rnd (unlike in
mpfr_rint
, rnd affects only how the exact fractional part is rounded, not how the fractional part is generated).
Set simultaneously iop to the integral part of op and fop to the fractional part of op, rounded in the direction rnd with the corresponding precision of iop and fop (equivalent to
mpfr_trunc(
iop,
op,
rnd)
andmpfr_frac(
fop,
op,
rnd)
). The variables iop and fop must be different. Return 0 iff both results are exact.
Set r to the value of x - n y, rounded according to the direction rnd, where n is the integer quotient of x divided by y, defined as follows: n is rounded toward zero for
mpfr_fmod
, and to the nearest integer (ties rounded to even) formpfr_remainder
andmpfr_remquo
.Special values are handled as described in Section F.9.7.1 of the ISO C99 standard: If x is infinite or y is zero, r is NaN. If y is infinite and x is finite, r is x rounded to the precision of r. If r is zero, it has the sign of x. The return value is the ternary value corresponding to r.
Additionally,
mpfr_remquo
stores the low significant bits from the quotient in *q (more precisely the number of bits in along
minus one), with the sign of x divided by y (except if those low bits are all zero, in which case zero is returned). Note that x may be so large in magnitude relative to y that an exact representation of the quotient is not practical.mpfr_remainder
andmpfr_remquo
functions are useful for additive argument reduction.