This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libfortran/48651] DTOA float conversion issue


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âÂâ


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]