home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!uvaarpa!cv3.cv.nrao.edu!laphroaig!cflatter
- From: cflatter@nrao.edu (Chris Flatters)
- Subject: Re: How is NaN recognized?
- Message-ID: <1992Sep10.163549.1593@nrao.edu>
- Sender: news@nrao.edu
- Reply-To: cflatter@nrao.edu
- Organization: NRAO
- References: <1992Sep8.231535.4925@ecl.psu.edu>
- Date: Thu, 10 Sep 1992 16:35:49 GMT
- Lines: 22
-
- In article 4925@ecl.psu.edu, y2t@ecl.psu.edu () writes:
- > What about reading floating point values from a binary file?
- >Look at the following codes:
- >
- >/** Suppose 'filename' is a file which was already created **/
- >/** using creat(), and was written using write(). **/
- >
- > int fp;
- > float x;
- > fp = open(filename, O_RONLY);
- > read(fp, &x, sizeof(float));
- >
- > Is there a way to detect if x is a NaN?
-
- Assuming IEEE-754:
-
- if (x != x) /* x is a NaN */
- else /* x is not a NaN */
-
- Chris Flatters
- cflatter@nrao.edu
-
-