Floating-point non-bug again?

Yuval Kfir yuvalk@mainsoft.com
Mon Jul 5 09:06:00 GMT 2004


Hello,
the short program below gives '5*1.2=5' when compiled
without -DDOUBLE_INTER, but '5*1.2=6' with the double-precision intermediate
variable.
Is this the same old non-bug? Why would it behave differently when storing
the result temporarily in a double?
Thanks,
- Yuval
--
Yuval Kfir, Kernel team
Mainsoft Corporation
yuvalk@mainsoft.com

#include <stdio.h>

int main (void)
{
   int i = 5;
#if defined(DOUBLE_INTER)
   double g = i * 1.2;
   i = g;
#else
   i *= 1.2;
#endif
   printf("5 * 1.2 = %d?\n",i);
   return 0;
}



More information about the Gcc-bugs mailing list