This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/5060: Comparisons between double on gcc 2.96
- From: rodrigc at gcc dot gnu dot org
- To: nobody at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 10 Dec 2001 19:46:01 -0000
- Subject: Re: c++/5060: Comparisons between double on gcc 2.96
- Reply-to: rodrigc at gcc dot gnu dot org
The following reply was made to PR c++/5060; it has been noted by GNATS.
From: rodrigc@gcc.gnu.org
To: chailan@sand.cad.cea.fr, gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org,
gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org
Cc:
Subject: Re: c++/5060: Comparisons between double on gcc 2.96
Date: 10 Dec 2001 19:43:54 -0000
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