This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/10902: comparing doubles is not consistent in gcc 3.3 (SuSE version)
- From: Jos van den Oever <jos at vandenoever dot info>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 21 May 2003 13:36:13 +0200
- Subject: Re: c++/10902: comparing doubles is not consistent in gcc 3.3 (SuSE version)
- References: <20030521102600.11431.qmail@sources.redhat.com>
Another addition to the report.
Comparing doubles in c does work properly:
#include <stdio.h>
#include <float.h>
int
main() {
double one = 1.0;
double belowone = 1.0-DBL_EPSILON;
if (one == belowone) {
printf("one == belowone\n");
} else {
printf("one != belowone\n");
}
if (1.0 == 1.0 - DBL_EPSILON) {
printf("1.0 == 1.0 - DBL_EPSILON\n");
} else {
printf("1.0 != 1.0 - DBL_EPSILON\n");
}
return 0;
}
gives output:
one != belowone
1.0 != 1.0 - DBL_EPSILON
which is what you'd expect.