issue with GMP library, a calculation issue

paul zimmermann Paul.Zimmermann at
Fri Nov 14 16:08:18 UTC 2014

> Please let me know if is there a way to get strings as exactly as I am setting them, to get 0.1224 but not 0.122399999999999994915000000(0)....
> Thanks
> Iulian

0.1224 = 153/1250 is not exactly representable in binary, thus you have to use
either a decimal floating-point library, or rational arithmetic. With a binary
floating-point library (mpf_t) you cannot avoid rounding.

Paul Zimmermann

More information about the gmp-discuss mailing list