I have the following code in FORTRAN 77:
REAL*8 :: dm
dm=1.-1.E-12
write(6,*) 'dm: ', dm
I get: dm: 1
Is this OK? I would like to get dm=0.999999999999
I have the following code in FORTRAN 77:
REAL*8 :: dm
dm=1.-1.E-12
write(6,*) 'dm: ', dm
I get: dm: 1
Is this OK? I would like to get dm=0.999999999999
As stated in a comment, you need to specify the precision of the constants. Also, real*8
is obsolete. (Was it always an extension?) Here is a modern way to write this, using the ISO Fortran Environment to obtain a 64-bit real type and using that type both in the declaration and in the constants.
use ISO_FORTRAN_ENV
real (real64) :: dm
dm = 1.0_real64 - 1.0E-12_real64
For more info, see What does `real*8` mean?