Round a mpq_t number to the nearest integer
Paul.Zimmermann at loria.fr
Tue May 19 11:25:13 CEST 2009
> 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?
> Kind regards,
yes. Note that when n/d is exactly between two integers, other ways
of breaking ties are possible.
More information about the gmp-discuss