%Qf in gmp_printf (was: Re: Wrong division ?)
paul zimmermann
Paul.Zimmermann at inria.fr
Wed Apr 6 13:12:50 UTC 2016
Pedro,
> mpz_t div = num / den
> mpz_t rem = num % den
> print(div)
> print(".")
> do (decimals) times:
> div = rem * 10 / den
> rem = rem * 10 % den
> print(div)
isn't the code below more efficient?
mpz_t div = (num * 10^decimals) / den
str = out (div)
print head (str, len(str) - decimals)
print "."
print tail (str, decimals)
Paul
More information about the gmp-discuss
mailing list