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?
Asked
Active
Viewed 1,361 times
1 Answers
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
- 53,608
- 15
- 131
- 222
-
Thanks!For my program turned out isfinite() is more useful, but I was not really specific with my question – Mihon Dec 09 '14 at 20:56
-
3C++ is: #include
and std::isnan(x) – Dec 09 '14 at 21:14