home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / fortran / 3069 < prev    next >
Encoding:
Internet Message Format  |  1992-08-17  |  2.0 KB

  1. Path: sparky!uunet!gatech!psuvax1!psuvm!hdk
  2. Organization: Penn State University
  3. Date: Mon, 17 Aug 1992 17:12:00 EDT
  4. From: H. D. Knoble <HDK@psuvm.psu.edu>
  5. Message-ID: <92230.171200HDK@psuvm.psu.edu>
  6. Newsgroups: comp.lang.fortran
  7. Subject: Re: how to quit on an NaN result?
  8. References: <1992Aug16.200837.14024@samba.oit.unc.edu>
  9.  <KHB.92Aug16143141@chiba.Eng.Sun.COM>
  10. Lines: 40
  11.  
  12. In article <KHB.92Aug16143141@chiba.Eng.Sun.COM>, khb@chiba.Eng.Sun.COM (Keith
  13. Bierman fpgroup) says:
  14.  
  15. >The fnonstd changing the way underflow works and trapping rather than
  16. >ignoring "ieee exceptions". Since I personally want proper underflow,
  17.  
  18. It could be claimed that floating-point underflow is not "proper". In
  19. fact wrong answers could be generated; and interrupt handling may be rather
  20. CPU time consuming. Two examples follow to illustrate these points.
  21.  
  22. Suppose the underflow threshold minimum is 10**(-79). Then
  23.  
  24. Y=1.E-40**2*1.E+20*1.E+40**2    is algebraically 1.E+20
  25.  
  26. but most exception (interrupt) handlers would set the intermediate result
  27. of an underflow to zero; thus the result for Y above would be 0.0 instead
  28. of 1.E+20 in this event.
  29.  
  30. Furthermore, in some cases at least, trapping such exceptions can be
  31. be very CPU expensive. For example, on an IBM 3090 (a reasonably fast
  32. CPU) the threshold is less than 1.E-40 (in this case ABS(16**(-65)) ).
  33. Using the IBM VS Fortran error trapping utility subroutine, ERRSET,
  34. handle underflows, one could run the program:
  35.  
  36.          IMPLICIT DOUBLE PRECISION (A-H,O-Z)
  37.          CALL ERRSET(208,256,-1,1,0,0)
  38.          SUM=0
  39.          X=1.E-40
  40.          DO 1 I=1,100000
  41.            SUM=SUM+X**2
  42.    1     CONTINUE
  43.          STOP
  44.          END
  45.  
  46. The result of this program is SUM=0, but it took 18 full seconds of IBM
  47. 3090 CPU time to get through the system and VS Fortran interrupt handling
  48. code!  Clearly, even if one isn't concerned about wrong results, this
  49. method should not be used to ignore underflows since it is over 400 times
  50. slower than using an IF statement (or using the equivalent VS Fortran
  51. run-time option NOXUFLOW).
  52.