2

I perform some Calculations with floats, and sometimes I divide a number by zero or even zero by zero. As a result, some values of my output array contain -1.#IND0000 values. After that I need to determine whether the value is "normal" or "NaN". How can I do it with if statement?

Mihon
  • 115
  • 9

1 Answers1

2

Try isnan(). That's the one you're looking for.

#include <math.h>

void YourCode() {

    float x = /* some value from your array here */;
    if (isnan(x)) { 
        // ... do stuff ...
    }

}
i_am_jorf
  • 52,428
  • 15
  • 126
  • 218