Rounding error

Paul Zimmermann Paul.Zimmermann at inria.fr
Wed Sep 8 08:27:42 UTC 2021


       Dear Frank,

> If I ever need correct rounding with GMP (I don't ATM), I think
> I could add 0.5e-P, then (like above) multiply by 1eP, convert to
> mpz_t and insert the decimal point manually.

since there is no documented error bound in the mpf computations,
there is no chance that this will (provably) work. The GMP manual says:

      Note that the 'mpf' functions are _not_ intended as a smooth
   extension to IEEE P754 arithmetic.  In particular results obtained on
   one computer often differ from the results on a computer with a
   different word size.

Of course you can add say 100 guard bits, then the probability to get an
incorrect rounding is about 2^-100...

Best regards,
Paul Zimmermann


More information about the gmp-bugs mailing list