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