How to check if float or double is NaN in C++
Checking for NaN
is simple since C++11:
#include <numeric>
bool isNaN = std::isnan(myNumber);
See the std::isnan
docs for reference.
You can also use the C99 function isnan
from <cmath>
:
#include <cmath>
bool isNaN = isnan(myDouble);