This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: INT(x) == 1 if x < 1?


program test_int
  WRITE(*,*) INT(0.9999999)
  WRITE(*,*) INT(0.99999999)
END PROGRAM

$ cat a.f90 program test_int WRITE(*,"(I5,1X,F15.12)") INT(0.9999999), 0.9999999 WRITE(*,"(I5,1X,F15.12)") INT(0.99999999), 0.99999999 END PROGRAM $ gfortran a.f90 && ./a.out 0 0.999999880791 1 1.000000000000

When you say "0.99999999", the compiler understands "the real number exactly representible for this kind (here, 4) that is closest to 0.99999999". It so happens that this number is 1.000000000000.

FX


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]