Thread View: comp.sys.next.programmer
2 messages
2 total messages
Started by J. G. Gregory
Fri, 20 Nov 1992 22:10
trapping NaN
Author: J. G. Gregory
Date: Fri, 20 Nov 1992 22:10
Date: Fri, 20 Nov 1992 22:10
6 lines
555 bytes
555 bytes
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
Re: trapping NaN
Author: Ralph Zazula
Date: Sat, 21 Nov 1992 18:13
Date: Sat, 21 Nov 1992 18:13
31 lines
1244 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads