This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Floating point problems (accuracy).
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: Phil Prentice <philp dot cheer at btinternet dot com>, gcc-help at gnu dot org, gcc at gnu dot org
- Cc: mike at stec dot clara dot co dot uk
- Date: Tue, 18 Jan 2005 14:05:53 -0600
- Subject: Re: Floating point problems (accuracy).
- References: <E1Cqyvy-00085r-Ad@monty-python.gnu.org>
Hi Phil,
>Does any one know a better way of fixing this? ... Is there a generic
solution?
There are several different strategies for addressing this kind of
problem. What's "The Best" strategy? Depends on your needs.
Some of the strategies:
1. hardware differences mean that different architectures may be
inconsistent with the less signficant bits (aka "the fiddly bits"). Expect
that to be the case, and live with it.
2. use strict IEEE 754 compliance throughout your program -- this does put
a considerable burden on the developers
3. avoid floating point; use fixed point or just integers for all your
calculations (this is The Answer if you absolutely MUST have the same
result on all platforms)
4. use software floating point (e.g., -msoft-float) -- be aware of the
significant performance penalty
HTH,
--Eljay