This is the mail archive of the
mailing list for the GCC project.
Re: Floating point trouble wit x86's extended precision
- From: Roger Sayle <roger at eyesopen dot com>
- To: Volker Reichelt <reichelt at igpm dot rwth-aachem dot de>
- Cc: gcc at gcc dot gnu dot org, <lucier at math dot purdue dot edu>
- Date: Wed, 20 Aug 2003 20:27:47 -0600 (MDT)
- Subject: Re: Floating point trouble wit x86's extended precision
> I wanted to construct a very extreme case where rounding leads to
> unexpected behaviour and came up with the following example:
> int main()
> double x = sqrt(2.0);
> volatile double y = x;
> if (x!=y) printf("Uh oh!\n");
> return 0;
> Compiling this with GCC 3.3.1 and using -O2 I get the output:
> "Uh oh!"
It should probably be pointed out that this may be a poor example
for GCC's WWW pages, as this particular test case is fixed in 3.4!
Mainline CVS evaluates sqrt(2.0) at compile-time and correctly
rounds it to double precision.
Perhaps, using sin(0.5) instead, will have a longer life-time...