This is the mail archive of the gcc@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]

Floating poing 'non-bug'? Or is this a bug?


Hello,
I posted this to gcc-bugs but received no response, perhaps someone here can
help me...

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;
}


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