Intentionally return NaN
return std::numeric_limits<double>::quiet_NaN();
I know it's an old question, but with C++11 you have the nan(const char*)
family of functions (nan
for doubles, nanl
for long doubles and nanf
for floats). The argument is implementation specific, but passing an empty string (e.g. nan("")
) returns a generic NaN value.
This should work:
#include <limits>
return std::numeric_limits<double>::quiet_NaN();