public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/66864] New: floor function error
@ 2015-07-14  5:04 dm577216smith at gmail dot com
  2015-07-14 17:04 ` [Bug fortran/66864] " kargl at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: dm577216smith at gmail dot com @ 2015-07-14  5:04 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-07-16 19:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-14  5:04 [Bug fortran/66864] New: floor function error dm577216smith at gmail dot com
2015-07-14 17:04 ` [Bug fortran/66864] " kargl at gcc dot gnu.org
2015-07-14 19:02 ` sgk at troutmask dot apl.washington.edu
2015-07-14 19:31 ` sgk at troutmask dot apl.washington.edu
2015-07-14 21:57 ` sgk at troutmask dot apl.washington.edu
2015-07-16 19:23 ` kargl at gcc dot gnu.org
2015-07-16 19:23 ` kargl at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).