Hello,

#include <stdio.h>
#include <stdint.h>


int main(void)
{
  double ratio = 0.21;
  printf("ration=%f ratio*10000000=%llu\n", ratio, (uint64_t)(10000000*ratio));

  return 0;
}

I compile its code and have 2 different result with 2 different gcc version.

with 4.4.1 :
$ gcc-4.4 -Wall y.c -o y-4.4
$ ./y-4.4
ration=0.210000 ratio*10000000=2099999

with 4.3.4 (I have same result with gcc 4.2.4/4.1.3/4.0.4)
$ gcc-4.3 -Wall y.c -o y-4.3
$ ./y-4.3
ration=0.210000 ratio*10000000=2100000

version info :

$ gcc-4.3 --version
gcc-4.3 (Ubuntu 4.3.4-5ubuntu1) 4.3.4
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc-4.4 --version
gcc (Ubuntu 4.4.1-4ubuntu8) 4.4.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ uname -a
Linux pouet 2.6.31-14-generic #48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009 i686
GNU/Linux


-- 
           Summary: regression on float representation
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vaillant dot etienne at gmail dot com


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

Reply via email to