tags:

views:

269

answers:

1

There a function like isNan (Javascript example) for Objective C ?. I just noticed this code is causing to display Nan % so i need to detect is a value is Nan so i could change it to 0

    [portefeuillePercentWaarde setText:[NSString stringWithFormat:@"%.2f%%", verschilPrencentage]];
+3  A: 

Try just adding

#include <math.h>

and then using the standard isnan() function to test.

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

double x;

// do some operation here
x = doSomething();
if (x != x)
  printf("%g is probably NaN, it's not equal to itself\n", x);
unwind
Thanks a lot this was really helpfull
Johnny Mast