Floating point trouble wit x86's extended precision
Roger Sayle
roger@eyesopen.com
Thu Aug 21 11:57:00 GMT 2003
[Apologies if you've received this twice, I screwed up the first time]
Hi Volker,
> 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...
Roger
--
Roger Sayle, E-mail: roger@eyesopen.com
OpenEye Scientific Software, WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road, Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507. Fax: (+1) 505-473-0833
More information about the Gcc
mailing list