[comp.sys.sgi] IRIS floating point read error

glennrp@BRL.ARPA (Glenn Randers-Pehrson, WMB) (02/26/88)

caution:

The FORTRAN READ statement can produce erroneous results when using
the IRIS floating point board, viz:

Script started on Fri Feb 26 08:37:42 1988
taurus.brl.mil> cat bug75.f
      program bug75
      character*4 temp
      temp='  75'
      read(temp,'(f4.0)')value
      ivalue=ifix(value)
      write(*,*)' value=',value,', ivalue=',ivalue
      end
taurus.brl.mil> f77 bug75.f         # not using the floating point board
taurus.brl.mil> a.out               # answer is correct
  value=+7.500000E+01, ivalue=75
taurus.brl.mil> f77 -Zf bug75.f     #  using the floating point board
taurus.brl.mil> a.out               # answer is wrong
  value=+7.499999E+01, ivalue=74
taurus.brl.mil> f77 -Zf -ZF+F bug75.f #  using fp board and accurate divide
taurus.brl.mil> a.out                 # answer is still wrong
  value=+7.499999E+01, ivalue=74
taurus.brl.mil> 
script done on Fri Feb 26 08:38:57 1988

Please don't send flames about the program.  I know and you know that
ivalue=nint(value) or ivalue=ifix(value+.5) will work properly in all cases.
But sometime you might inherit a program containing coding as above, as I
did, and be baffled for a while.

The example above was run on an IRIS 2500 Turbo, with Rev C FP1 board,
running release GL2-W3.5rl. I got the same results on a 3130 and a 3030..

Glenn Randers-Pehrson <glennrp@brl.arpa>

blbates@AERO4.LARC.NASA.GOV (Bates TAD/HRNAB ms294 x2601) (02/27/88)

You shouldn't have to add the .5 to your sample case, it should work as is.
I have had similar problems with programs.  A set of subroutines work fine
everyplace, but on our IRIS.  I avoid doing ANY calculations on our IRIS
that require any accuracy.