home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / next / programm / 7377 < prev    next >
Encoding:
Text File  |  1992-11-23  |  1.1 KB  |  38 lines

  1. Newsgroups: comp.sys.next.programmer
  2. Path: sparky!uunet!psinntp!juliet!news
  3. From: frank@fnbc.com (Frank Mitchell)
  4. Subject: Re: trapping NaN
  5. Message-ID: <1992Nov23.161217.23247@fnbc.com>
  6. Sender: news@fnbc.com
  7. Organization: First National Bank Of Chicago, Chicago IL, USA
  8. References: <1992Nov21.111335.4014@arizona.edu>
  9. Distribution: world,local
  10. Date: Mon, 23 Nov 92 16:12:17 GMT
  11. Lines: 25
  12.  
  13. In article <1992Nov21.111335.4014@arizona.edu>  writes:
  14. > In article <1992Nov20.221038.1170@proforma.com>  writes:
  15. > > I would like to trap NaN -- the "not a number" condition that floating  
  16. point  
  17. > > values can take.
  18. > It turns out that (NaN != NaN) is true.  So, in some code I did before, I  
  19. used:
  20. > if(x == x) {    /* x is NOT NaN */
  21. > < use x>
  22. > }
  23. > else {
  24. > <whatever for the NaN case>
  25. > }
  26.  
  27. I tend to use the finite() call, which also traps infinities (which may 
  28. be good or bad).  Check out its man page for details.
  29.  
  30. --
  31. Frank Mitchell,    Business Systems Analyst, First National Bank of Chicago
  32. email:frank@fnbc.com (NeXTmail)
  33.  
  34. A happy child is merely an unhappy child who is having fun.
  35. -- Morticia Addams
  36.