This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Kahan's Floating Point Test



----- Original Message -----
From: "Stephen L Moshier" <moshier@mediaone.net>
To: "Michael Price" <mprice@atl.imco.com>
Cc: <gcc@gcc.gnu.org>
Sent: Wednesday, May 30, 2001 9:51 AM
Subject: Re: Kahan's Floating Point Test


> > 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.
>
One of the necessary modifications to Paranoia to make it work with
extended width register architectures (which go back at least 20 years
prior to x86) is to force storage to memory at strategic places.  I don't
totally understand why Kahan didn't do this, as he was (AFAIK) an advocate
of such architectures and their incorporation into IEEE standards. As
Stephen points out, failing to do this, even after setting precision mode,
will produce inconsistencies in exponent range.  I expect the same would
happen on some PowerPC architectures.  -ffloat-store will not solve the
problem, as it will kick in where it is not wanted and sometimes not where
it is wanted.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]