This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/66864] New: floor function error
- From: "dm577216smith at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 14 Jul 2015 05:04:36 +0000
- Subject: [Bug fortran/66864] New: floor function error
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66864
Bug ID: 66864
Summary: floor function error
Product: gcc
Version: 5.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: dm577216smith at gmail dot com
Target Milestone: ---
Here is a small program showing an error in the FLOOR function on my machine.
I get similar results with gfortran 5.1 and also an older 4.6 version.
I noticed that each of the incorrect results, 94906264, 777666496, and
2000111104
seem to be the correct value chopped to 24 bits.
Also, if I compile the program with 64-bit integers with -fdefault-integer-8,
all the results are ok.
PROGRAM T
DOUBLE PRECISION :: X
WRITE (*,*) ' '
X = 2.0D0 ** 26.5D0
WRITE (*,*) ' X = 2.0D0 ** 26.5D0 = ', X
WRITE (*,*) ' FLOOR(X) = ', FLOOR(X)
WRITE (*,*) ' '
WRITE (*,*) ' But FLOOR( 2.0D0 ** 26.5D0 ) = ', FLOOR( 2.0D0 ** 26.5D0 )
WRITE (*,*) ' '
WRITE (*,*) ' '
X = 777666555.6D0
WRITE (*,*) ' X = 777666555.6D0 gives ', X,' FLOOR(X) = ', FLOOR(X)
WRITE (*,*) ' '
WRITE (*,*) ' But FLOOR(777666555.6D0) = ', FLOOR(777666555.6D0)
WRITE (*,*) ' '
WRITE (*,*) ' '
X = 2000111222.6D0
WRITE (*,*) ' X = 2000111222.6D0 gives ', X,' FLOOR(X) = ', FLOOR(X)
WRITE (*,*) ' '
WRITE (*,*) ' But FLOOR(2000111222.6D0) = ', FLOOR(2000111222.6D0)
WRITE (*,*) ' '
WRITE (*,*) ' '
END PROGRAM T
Output from the program:
X = 2.0D0 ** 26.5D0 = 94906265.624251559
FLOOR(X) = 94906265
But FLOOR( 2.0D0 ** 26.5D0 ) = 94906264
X = 777666555.6D0 gives 777666555.60000002 FLOOR(X) = 777666555
But FLOOR(777666555.6D0) = 777666496
X = 2000111222.6D0 gives 2000111222.5999999 FLOOR(X) = 2000111222
But FLOOR(2000111222.6D0) = 2000111104