std::nan,std::nanf,std::nanl (3) - Linux Manuals
std::nan,std::nanf,std::nanl: std::nan,std::nanf,std::nanl
NAME
std::nan,std::nanf,std::nanl - std::nan,std::nanf,std::nanl
Synopsis
Defined in header <cmath>
float nanf( const char* arg ); (since C++11)
double nan( const char* arg ); (since C++11)
long double nanl( const char* arg ); (since C++11)
Converts the implementation-defined character string arg into the corresponding quiet NaN value, as if by calling std::strtod, std::strtof, or std::strtold, respectively, as follows:
The call std::nan("n-char-sequence"), where n-char-sequence is a sequence of digits, Latin letters, and underscores, is equivalent to the call std::strtod("NAN(n-char-sequence)", (char**)nullptr);.
The call std::nan("") is equivalent to the call std::strtod("NAN()", (char**)nullptr);.
The call std::nan("string"), where string is neither an n-char-sequence nor an empty string, is equivalent to the call std::strtod("NAN", (char**)nullptr);.
Parameters
arg - narrow character string identifying the contents of a NaN
Return value
The quiet NaN value that corresponds to the identifying string arg or zero if the implementation does not support quiet NaNs.
Example
// Run this code
Possible output:
See also
isnan checks if the given number is NaN
(C++11)
NAN evaluates to a quiet NaN of type float
(C++11)
has_quiet_NaN identifies floating-point types that can represent the special value "quiet not-a-number" (NaN)
[static]
has_signaling_NaN identifies floating-point types that can represent the special value "signaling not-a-number" (NaN)
[static]
quiet_NaN returns a quiet NaN value of the given floating-point type
[static]
signaling_NaN returns a signaling NaN value of the given floating-point type
[static]