On Tue, 2012-03-13 at 09:21 -0700, W.J. Metzger wrote: > On Tue, 13 Mar 2012, Cyber Joy wrote: > > > Why does this happen? > > > > Dear Cyber Joy, > > I guess your question is why you get 12 13 12 rather than 13 13 12. > > Try the attached file. If you don't know what the epsilon function is, look it up, e.g., > > http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gfortran/EPSILON.html > > You will see that 1d-16 is too small to be added to 12. In other words adding 1d-16 is equivalent to adding zero. > > Cheers, Wes > > P.S. from your 'name' I would have thought you would have had more fun figuring this out yourself rather than asking the list. Try this. Maybe it will illuminate. As several have pointed out, floating-point isn't the same as integer, binary isn't the same as decimal, and fixed precision isn't the same as unlimited precision. program test print *, int(4.8d0/0.4d0+1.0d-16)+1, nint(4.8d0/0.4d0+1.0d-16)+1 print *, int(4.8d0/0.4d0+1.0d-5)+1, nint(4.8d0/0.4d0+1.0d-5)+1 print *, int(4.8d0/0.4d0)+1, nint(4.8d0/0.4d0)+1 end program test