Round a mpq_t number to the nearest integer

Paul Zimmermann Paul.Zimmermann at loria.fr
Tue May 19 11:25:13 CEST 2009


> Hello,
> Thanks for your reply.
> By rounding to the nearest integer I mean to add 1/2 to mpq
> fraction(n/d),and taking the floor of the result.Is what you prpose
> (i.e. dividing 2n+d by 2d with rounding towards -Infinity)
> equivalent to this?
> Thanks,
> Kind regards,
> B.

yes. Note that when n/d is exactly between two integers, other ways
of breaking ties are possible.

Paul Zimmermann


More information about the gmp-discuss mailing list