http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48651

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thenlich at users dot
                   |                            |sourceforge.net

--- Comment #1 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-04-17 
18:07:27 UTC ---
Well, this is not a libgfortran issue. I am not convinced it is actually a
problem either.  The resulting value from printf swings to the other side for
double or long double.

#include <stdio.h>

int
main ()
{
  float num = 0.9;
  double dnum = 0.9;
  long double ldnum = 0.0;
  printf("%30.28f\n", num);
  printf("%30.28lf\n", num);
  printf("%30.28f\n", dnum);
  printf("%30.28lf\n", dnum);
  printf("%30.28f\n", ldnum);
  printf("%30.28lf\n", ldnum);
}

Gives:

$ ./a.out 
0.8999999761581420898437500000
0.8999999761581420898437500000
0.9000000000000000222044604925
0.9000000000000000222044604925
0.9000000000000000222044604925
0.9000000000000000222044604925

The result flips to the other side of .9 which is not necessarily wrong.

0.9 - 0.8999999761581420898437500000 = 2.384185791×10⁻⁸

0.9 - 0.9000000000000000222044604925 = −2.220446049×10⁻¹⁷

Reply via email to