The way how I create my mpf_class effects the result after a arithmetic operation

Torbjörn Granlund tg at gmplib.org
Wed Jan 28 12:55:42 UTC 2015


You need to understand the nature of binary floating-point better.

In short, the numbers you use, 6.4 and 3.4, cannot be stored exactly in
binary FP.  3.4 for example, is 1101100110011001100110011001100110...
where the repeting tail's length depends on the format's precision.

Your 3.4 stored in a IEEE double and stored in a default precision mpf
number will very likely be different, and in both cases relatively poor
approximations.

-- 
Torbjörn
Please encrypt, key id 0xC8601622


More information about the gmp-discuss mailing list