Floating-point accuracy

Joel Parker jjk3@AE.MsState.EDU
Wed Aug 9 17:22:00 GMT 2006


I'm having some trouble with floating-point accuracy in g77 and gfortran,
and I'm starting to think I'm missing something obvious.

I've created (and attached) a small test program that does a calculation
with REAL*8 numbers and prints the result. I've tested this program using
the following systems:

Pentium 4 / Ubuntu 6.06 (fully updated)
    g77 3.4.6
    gfortran 4.0.3
    MATLAB 7.0.1

SPARCv9 / Solaris (unknown version)
    f77: Sun WorkShop 6 update 2 FORTRAN 77 5.3
    g77 0.5.23 (gcc 2.8.1)

TI-89 handheld calculator

The calculator, MATLAB, and Sun's f77 all give 1.06603949 as the answer.
The GNU compilers on both systems all give 1.06603696.

Is there something I'm missing here?

Thanks in advance,

joeljkp
-------------- next part --------------
      PROGRAM TEST

      REAL*8 N1, N2, N3, ANS

      N1 = 2453957.09236
      N2 = 2415020.0
      N3 = 36525.0

      ANS = (N1 - N2) / N3

      WRITE(UNIT=*,FMT=*) ANS

      STOP
      END


More information about the Fortran mailing list