Next: Miscellaneous Functions, Previous: Input and 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 towards 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 the nearest mode (where halfway cases are rounded to an even integer or mantissa). 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 towards 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).