IsNan in lens c

There is a function like isNan (a Javascript example) for Objective C ?. I just noticed that this code causes Nan% to display, so I need to determine the value of Nan, so I can change it to 0

     [portefeuillePercentWaarde setText: [NSString stringWithFormat: @ "%. 2f %%", verschilPrencentage]];
+3
iphone
Jan 21 '10 at 12:50
source share
1 answer

Try to add

#include <math.h> 

and then using the standard isnan() function for testing.

You can also use the "trick" that NaN is not equal to anyone, including yourself:

 double x; // do some operation here x = doSomething(); if (x != x) printf("%g is probably NaN, it not equal to itself\n", x); 
+20
Jan 21 '10 at 12:55
source share



All Articles