std::numeri...::quiet_NaN(3)
πΈ NAME πΈ
Okay bestie, welcome to the page for std::numeric_limits::quiet_NaN β the manual header calls it std::numeri...::quiet_NaN(3) and says it's from the C++ Standard Libary (their spelling, not mine π
). The NAME line is literally std::numeric_limits::quiet_NaN - std::numeric_limits::quiet_NaN, which is giving βI contain multitudes but also just my own name.β π«Ά
π¦ Synopsis π¦
static T quiet_NaN() throw(); (until C++11)
static constexpr T quiet_NaN() noexcept; (since C++11)
Returns the special value "quiet not-a-number", as represented by the floating-point type T. Only meaningful if std::numeric_limits<T>::has_quiet_NaN == true. In IEEE 754, the most common binary representation of floating-point numbers, any value with all bits of the exponent set and at least one bit of the fraction set represents a NaN. It is implementation-defined which values of the fraction represent quiet or signaling NaNs, and whether the sign bit is meaningful.
π Return value π
Here's the whole return-value roster, no gatekeeping, no skipped entries:
Tβstd::numeric_limits<T>::quiet_NaN()/* non-specialized */βT()boolβfalsecharβ0signed charβ0unsigned charβ0wchar_tβ0char8_t(since C++20) β0char16_t(since C++11) β0char32_t(since C++11) β0shortβ0unsigned shortβ0intβ0unsigned intβ0longβ0unsigned longβ0long long(since C++11) β0unsigned long long(since C++11) β0floatβ implementation-defined (may beNAN)doubleβ implementation-definedlong doubleβ implementation-defined
π Notes π
Two little caveats with main-character energy:
- A NaN never compares equal to itself.
- Copying a NaN may not preserve its bit representation.
π Example π
Several ways to generate a NaN (the output string is compiler-specific). The page also has a literal // Run this code line right before the snippet, so here's the snippet:
#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';
}
β Possible output β
nan nan nan nan nan -nan -nan
NaN == NaN? false
π See also π
has_quiet_NaNβ identifies floating-point types that can represent the special value"quiet not-a-number"(NaN)[static](public static member constant)signaling_NaNβ returns a signaling NaN value of the given floating-point type[static](public static member function)nan,nanf,nanlβ not-a-number (NaN)(C++11)(function)(C++11)(C++11)isnanβ checks if the given number is NaN(C++11)(function)
Alright bestie, that's the whole page π β source http://cppreference.com, date 2024.06.10, and the page is std::numeri...::quiet_NaN(3). Stay floaty! πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms