[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: g++ 3.4.2 strange behavior
From: |
John Max Skaller |
Subject: |
Re: g++ 3.4.2 strange behavior |
Date: |
Tue, 09 Nov 2004 00:44:29 +1100 |
User-agent: |
Pan/0.13.3 (That cat's something I can't explain) |
On Mon, 01 Nov 2004 20:42:13 +0100, Paul Schneider wrote:
This:
(1000.0 - 0.00) / 0.01
is an 'arithmetic constant expression' whereas this:
(b-a)/c
is not (see ISO C++ 5.19/3). So I think what is happening
is that the first case is evaluated at compile time,
and the second at run time. It seems that the
evaluations produce different results.
Try this option:
-ffloat-store
Do not store floating point variables in registers, and inhibit
other options that might change whether a floating point value is
taken from a register or memory.
This option prevents undesirable excess precision on machines such
as the 68000 where the floating registers (of the 68881) keep more
precision than a "double" is supposed to have. Similarly for the
x86 architecture. For most programs, the excess precision does
only good, but a few programs rely on the precise definition of
IEEE floating point. Use -ffloat-store for such programs, after
modifying them to store all pertinent intermediate computations
into variables.