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]

Re: c++/5060: Comparisons between double on gcc 2.96


Synopsis: Comparisons between double on gcc 2.96

State-Changed-From-To: open->analyzed
State-Changed-By: rodrigc
State-Changed-When: Mon Dec 10 11:43:54 2001
State-Changed-Why:
    Reproduced with gcc 3.0 and gcc 3.1 on Linux on x86.
    
    The problem goes away if I change your testcase to:
    
    #include <cstddef>
    #include <iostream>
    #include <cstdio>
    using namespace std;
     
    int main()
    {
       double x = 0.0 ;
       std::cout << "Testing floating point behaviour" << std::endl ;
       for( double i=1 ; i<10 ; i++ )
       {
          double z = 1.0/i ;
          double o_x = x ;
          x = x + z ;
          printf("i:%g %20.20g %20.20g   ", i, z+ o_x, x);
          double q = o_x+z;
          //if( ! (x==(double)(o_x+z))) std::cout <<"HELP!";
          if( ! (x==q)) std::cout <<"HELP!";
          std::cout << std::endl;
     
       }
     
    }

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=5060&database=gcc


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