Re: c++/10902: comparing doubles is not consistent in gcc 3.3 (SuSE version)

Jos van den Oever <[email protected]>
Newsgroups gmane.comp.gcc.prs
Message-ID <[email protected]>
The following reply was made to PR c++/10902; it has been noted by GNATS.

From: Jos van den Oever <[email protected]>
To: [email protected], [email protected]
Cc:  
Subject: Re: c++/10902: comparing doubles is not consistent in gcc 3.3 (SuSE version)
Date: Wed, 21 May 2003 13:34:16 +0200

 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.