GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::nan,std::nanf,std::nanl(3) C++ Standard Libary std::nan,std::nanf,std::nanl(3)

std::nan,std::nanf,std::nanl - std::nan,std::nanf,std::nanl


Defined in header <cmath>
float nanf( const char* arg ); (1) (since C++11)
double nan( const char* arg ); (2) (since C++11)
long double nanl( const char* arg ); (3) (since C++11)


Converts the character string arg into the corresponding quiet NaN value, as if by
calling std::strtof, std::strtod, or std::strtold, respectively.


1) The call std::nanf("n-char-sequence"), where n-char-sequence is a sequence of
digits, ASCII letters, and underscores, is equivalent to the call
std::strtof("NAN(n-char-sequence)", (char**)nullptr);.
The call std::nanf("") is equivalent to the call std::strtof("NAN()",
(char**)nullptr);.
The call std::nanf("string"), where string is neither an n-char-sequence nor an
empty string, is equivalent to the call std::strtof("NAN", (char**)nullptr);.
2) Same as (1), but calls std::strtod instead of std::strtof.
3) Same as (1), but calls std::strtold instead of std::strtof.


arg - narrow character string identifying the contents of a NaN


The quiet NaN value that corresponds to the identifying string arg or zero if the
implementation does not support quiet NaNs.


If the implementation supports IEEE floating-point arithmetic (IEC 60559), it also
supports quiet NaNs.


This function is not subject to any of the error conditions specified in
math_errhandling.

// Run this code


#include <iostream>
#include <cmath>
#include <cstdint>
#include <cstring>


int main()
{
double f1 = std::nan("1");
std::uint64_t f1n; std::memcpy(&f1n, &f1, sizeof f1);
std::cout << "nan(\"1\") = " << f1 << " (" << std::hex << f1n << ")\n";


double f2 = std::nan("2");
std::uint64_t f2n; std::memcpy(&f2n, &f2, sizeof f2);
std::cout << "nan(\"2\") = " << f2 << " (" << std::hex << f2n << ")\n";
}


nan("1") = nan (7ff0000000000001)
nan("2") = nan (7ff0000000000002)


isnan checks if the given number is NaN
(C++11) (function)
NAN evaluates to a quiet NaN of type float
(C++11) (macro constant)
has_quiet_NaN identifies floating-point types that can represent the special
[static] value "quiet not-a-number" (NaN)
(public static member constant of std::numeric_limits<T>)
has_signaling_NaN identifies floating-point types that can represent the special
[static] value "signaling not-a-number" (NaN)
(public static member constant of std::numeric_limits<T>)
quiet_NaN returns a quiet NaN value of the given floating-point type
[static] (public static member function of std::numeric_limits<T>)
signaling_NaN returns a signaling NaN value of the given floating-point type
[static] (public static member function of std::numeric_limits<T>)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.