home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / fortran / 3065 < prev    next >
Encoding:
Text File  |  1992-08-17  |  1.2 KB  |  29 lines

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!jvnc.net!yale.edu!cmcl2!psinntp!psinntp!isc-newsserver!jsvrc
  3. From: jsvrc@rc.rit.edu (J A Stephen Viggiano)
  4. Subject: Re: how to quit on an NaN result?
  5. Message-ID: <1992Aug17.155913.21922@ultb.isc.rit.edu>
  6. Sender: news@ultb.isc.rit.edu (USENET News System)
  7. Nntp-Posting-Host: rcmain.rc.rit.edu
  8. Organization: RIT Research Corp
  9. References: <1992Aug16.200837.14024@samba.oit.unc.edu>
  10. Date: Mon, 17 Aug 1992 15:59:13 GMT
  11. Lines: 16
  12.  
  13. In article <1992Aug16.200837.14024@samba.oit.unc.edu> Bruce.Scott@bbs.oit.unc.edu (Bruce Scott) writes:
  14.  
  15. > How can I check for NaN's and quit when one arises. Does one use
  16. >        if (avar .eq. 'NaN') stop
  17. >or is this illegal?
  18.  
  19. The answers are: No, and No, respectively. I tried this a couple of years ago,
  20. and proposely put some NaNs through. (I didn't include the quotes in the
  21. test, though.) The test always failed, because NaNs are unordered, so one
  22. can never equal another. (This might be compiler-dependent, though.)
  23.  
  24. A portable way is to use an internal write. Write a known NaN to
  25. a character variable, use the substring that flags the result as a NaN.
  26. Then, write the value you want to test to another character variable, and
  27. compare *these* variables.
  28.  
  29.