At 19:04 2002-10-15 -0400, you wrote:
>What's the best way to test for a float being set to nan or -nan? I found
>that the following conditional statement works --
>
> if (value<0 || value>=0)
> {
> // do nothing -- its a normal number
> }
> else
> {
> // we have -nan or nan, return
> return wPt;
> }
>
>-- but it seems a bit of a kluge. Is there a better way to test this?
A NaN (not a number) will never be equal to itself. If value is a float or
double, then writing
if (value != value) { /* value is NaN */ }
is a quicker way. If a full C99 standard library was available, then using
the fpclassify call would be the cleanest method.
--
Ben Combee <[EMAIL PROTECTED]>
CodeWarrior for Palm OS technical lead
Palm OS programming help @ www.palmoswerks.com
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/