home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / c / 13468 < prev    next >
Encoding:
Text File  |  1992-09-10  |  970 b   |  35 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!uvaarpa!cv3.cv.nrao.edu!laphroaig!cflatter
  3. From: cflatter@nrao.edu (Chris Flatters)
  4. Subject: Re: How is NaN recognized?
  5. Message-ID: <1992Sep10.163549.1593@nrao.edu>
  6. Sender: news@nrao.edu
  7. Reply-To: cflatter@nrao.edu
  8. Organization: NRAO
  9. References: <1992Sep8.231535.4925@ecl.psu.edu>
  10. Date: Thu, 10 Sep 1992 16:35:49 GMT
  11. Lines: 22
  12.  
  13. In article 4925@ecl.psu.edu, y2t@ecl.psu.edu () writes:
  14. >    What about reading floating point values from a binary file? 
  15. >Look at the following codes:
  16. >
  17. >/**   Suppose 'filename' is a file which was already created  **/
  18. >/**   using creat(), and was written using write().           **/
  19. >
  20. >      int    fp;
  21. >      float  x;
  22. >      fp = open(filename, O_RONLY);
  23. >      read(fp, &x, sizeof(float));
  24. >
  25. >    Is there a way to detect if x is a NaN?
  26.  
  27. Assuming IEEE-754: 
  28.  
  29.     if (x != x) /* x is a NaN */
  30.     else        /* x is not a NaN */
  31.  
  32.     Chris Flatters
  33.     cflatter@nrao.edu
  34.  
  35.