std::numeric_limits<T>::quiet_NaN
Min standard notice:
Returns the special value “quiet not-a-number”, as represented by the floating-point type T. Only meaningful if std::numeric_limits
# Declarations
static T quiet_NaN() throw();
(until C++11)
static constexpr T quiet_NaN() noexcept;
(since C++11)
# Notes
A NaN never compares equal to itself. Copying a NaN may not preserve its bit representation.
# Example
#include <iostream>
#include <limits>
#include <cmath>
int main()
{
std::cout << std::numeric_limits<double>::quiet_NaN() << ' ' // nan
<< std::numeric_limits<double>::signaling_NaN() << ' ' // nan
<< std::acos(2) << ' ' // nan
<< std::tgamma(-1) << ' ' // nan
<< std::log(-1) << ' ' // nan
<< std::sqrt(-1) << ' ' // -nan
<< 0 / 0.0 << '\n'; // -nan
std::cout << "NaN == NaN? " << std::boolalpha
<< ( std::numeric_limits<double>::quiet_NaN() ==
std::numeric_limits<double>::quiet_NaN() ) << '\n';
}