This is the mail archive of the 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

> 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.

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