home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!news.cs.indiana.edu!arizona.edu!arizona.edu!news
- Newsgroups: comp.sys.next.programmer
- Subject: Re: trapping NaN
- Message-ID: <1992Nov21.111335.4014@arizona.edu>
- From: zazula@pri.com (Ralph Zazula)
- Date: 21 Nov 92 11:13:35 MST
- Reply-To: zazula@pri.com
- References: <1992Nov20.221038.1170@proforma.com>
- Distribution: world,local
- Nntp-Posting-Host: bonehead.tucson.az.us
- Lines: 31
-
- In article <1992Nov20.221038.1170@proforma.com> writes:
- > I would like to trap NaN -- the "not a number" condition that floating point
- > values can take. I can't find any clue on how to do this, except some
- cryptic
- > stuff in the man pages under "math". Is there some signal I can handle?
- >
- > Thanks in advance.
- > --J Gregory
-
- Hi -
-
- It turns out that (NaN != NaN) is true. So, in some code I did before, I used:
-
- if(x == x) { /* x is NOT NaN */
- < use x>
- }
- else {
- <whatever for the NaN case>
- }
-
- Here's the excerpt from the manual page:
-
- "If x != x then x is NaN; every other predicate (x > y, x = y, x < y,...) is
- FALSE if NaN is involved."
-
- Ralph
- ---
- Ralph Zazula
- Pinnacle Research, Inc.
- zazula@pri.com (NeXT Mail)
- (602)529-1135
-