Question about mpf_add

Torbjorn Granlund tg at
Sat Oct 4 20:42:10 CEST 2008

"Bruce M. Axtens" <bruce.axtens at> writes:

  G'day everyone
   Microsoft Visual C++ 6.0
   Windows XP Professional SP3
  In the code below I use mpf_add in what I assume to be the canonical way.
  What I don't understand at this point is why 2.2 + 3.2 =
  5.39999999999999999999999999999999999999. I would have thought that
  gmp was smart enough to give 5.4.
  What else should I be seeing in the manual that I'm not?
I don't think this sort of issues is spelled out in the manual, it is
beyond its scope.

While 2.2 and 3.2 are representable exactly in base 10, they are not
in binary, and neither is their sum..  Therefore, any base-2 floating
point system will never get the sum 5.4 exactly, but 5.4+epsilon or


More information about the gmp-discuss mailing list