[Bug fortran/54159] Fortran quad precision rounding seemingly nonsensical
kargl at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Aug 2 15:24:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54159
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #5 from kargl at gcc dot gnu.org 2012-08-02 15:23:51 UTC ---
(In reply to comment #4)
> 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/
>
You don't need to resort to that URL.
program quad_test
implicit none
integer, parameter :: dp = kind(0d0)
integer, parameter :: qp = selected_real_kind(32)
real(qp) :: qpreal1, qpreal2
! Two quad prec numbers that differ by last 3 digits
qpreal1 = 42246.3973278316589130554348230362000_qp
qpreal2 = 42246.3973278316589130554348230361940_qp
print '(A,Z32)', "qpreal1 = ", qpreal1
print '(A,Z32)', "qpreal2 = ", qpreal2
print *
print '(A,Z16)', "trunc qpreal1 = ", real(qpreal1, kind=dp)
print '(A,Z16)', "trunc qpreal2 = ", real(qpreal2, kind=dp)
end program quad_test
laptop:kargl[225] gfortran46 -o z -rpath /usr/local/lib/gcc46 a.f90
laptop:kargl[226] ./z
qpreal1 = 400E4A0CCB6E8DB58800000000000001
qpreal2 = 400E4A0CCB6E8DB58800000000000000
trunc qpreal1 = 40E4A0CCB6E8DB59
trunc qpreal2 = 40E4A0CCB6E8DB58
More information about the Gcc-bugs
mailing list