This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Kahan's Floating Point Test
- To: Michael Price <mprice at atl dot imco dot com>
- Subject: Re: Kahan's Floating Point Test
- From: Stephen L Moshier <moshier at mediaone dot net>
- Date: Wed, 30 May 2001 12:51:22 -0400 (EDT)
- cc: gcc at gcc dot gnu dot org
- Reply-To: moshier at moshier dot ne dot mediaone dot net
> Its annoying to have a program that heavily uses floating
> point math to produce the same output on FreeBSD and Solaris but
> different output on Linux.
It's annoying to see this question come up repeatedly, too! Don't
we have a FAQ paragraph about this?
The floating point hardware on x86 is not IEEE compliant. You can
come close by setting the rounding precision of the fpu to the desired
working precision of the numbers. See /usr/include/fpu_control.h
on linux for the functions or macros to do that.
After setting the precision there will still be an occasional problem
when the exponent goes outside the range of the desired precision.
PARANOIA usually complains about a problem with tiny denormal numbers
because of that. You have to ensure the result is written out from
the fpu to memory in order to fix this problem. The float-store
switch of GCC will force some, but not all, results to be written out.
If you didn't already know this was a problem, the chances are that
you will not be much affected by it. But you should (always anyway)
avoid careless comparisons between floating point values.