🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.next.programmer
Article #1876

Re: trapping NaN

#1876
From: Ralph Zazula
Date: Sat, 21 Nov 1992 18:13
31 lines
1244 bytes
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
Technical Details
Message-ID: <1992Nov21.111335.4014@arizona.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!news.cs.indiana.edu!arizona.edu!arizona.edu!news
References: <1992Nov20.221038.1170@proforma.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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