pub unsafe extern "C" fn mp_rat_to_decimal(
r: mp_rat,
radix: mp_size,
prec: mp_size,
round: mp_round_mode,
str_: *mut c_char,
limit: c_int,
) -> mp_result
Expand description
Converts the value of r
to a string in decimal-point notation with the
specified radix, writing no more than limit
bytes of data to the given
output buffer. It generates prec
digits of precision, and requires
MP_MIN_RADIX <= radix <= MP_MAX_RADIX
.
Ratios usually must be rounded when they are being converted for output as a decimal value. There are four rounding modes currently supported:
MP_ROUND_DOWN Truncates the value toward zero. Example: 12.009 to 2dp becomes 12.00
MP_ROUND_UP Rounds the value away from zero: Example: 12.001 to 2dp becomes 12.01, but 12.000 to 2dp remains 12.00
MP_ROUND_HALF_DOWN Rounds the value to nearest digit, half goes toward zero. Example: 12.005 to 2dp becomes 12.00, but 12.006 to 2dp becomes 12.01
MP_ROUND_HALF_UP Rounds the value to nearest digit, half rounds upward. Example: 12.005 to 2dp becomes 12.01, but 12.004 to 2dp becomes 12.00