http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54159

--- Comment #4 from Jonathan Hogg <jonathan.hogg at stfc dot ac.uk> 2012-08-02 
11:37:17 UTC ---
I can confirm that if we fiddle the fp rounding mode using a bit of C (very
similar to the one you just suggested) then the problem goes away for this
example.


With your clue and looking at the binary representation we can see the probable
cause:

If we believe the output of http://babbage.cs.qc.cuny.edu/IEEE-754/

Then the binary representation for the qp mantissa is
1.0100101000001100110010110110111010001101101101011000100000000000000000000000000000000000000000000000000000000000
vs
1.0100101000001100110010110110111010001101101101011000100000000000000000000000000000000000000000000000000000000001

between qpreal1 and qpreal2. These differ only in the last binary digit.

A double precision mantissa is
1.0100101000001100110010110110111010001101101101011001

If you line these up in a text editor, the truncation occurs such that the
100000000000000000000000000000000000000000000000000000000001 part needs got rid
of, which seems incorrectly rounded (if I've not made a mistake)

Of course, if the correct qp mantissas are
1.0100101000001100110010110110111010001101101101011000011111111111111111111111111111111111111111111111111111111111
vs
1.0100101000001100110010110110111010001101101101011000100000000000000000000000000000000000000000000000000000000000

the rounding mode would make a difference.

Apologies for mistaking floating point behavior for a bug.

Reply via email to