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