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]
Other format: [Raw text]

Re: Floating point problems (accuracy).


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


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