critical bug in mpf_set_str

Torbjorn Granlund tg at
Mon Feb 16 19:38:26 CET 2004

Paul.Zimmermann at (Paul Zimmermann) writes:

  There is a critical bug in gmp-4.1.2: two equal (up to trailing zeros) 
  strings are converted into different floating-point numbers:
  mermoz% gcc gmp_bug.c -lgmp
  mermoz% ./a.out 
  x=0.111101010111e15 and
  y=0.111101010111e15 equal
  x=0.111101010111e15 and
  y=0.111101010111e15 differ

I would argue that this is not a bug, it is merely a surprising
effect of rounding.  There are a few rough corners in mpf of this

We have been considering to refine mpf to handle rounding better.
Its current "rounding" is basically just chopping, which at best
means rounding towards zero.


More information about the gmp-bugs mailing list