English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C ++returns a double type NaN value (not a number).
The function in<cmath>Defined in the header file.
double nan(const char* arg);
Similarly, nanf and nanl return NaN values of type float and long double.
Specific to the implementation C string. If the string is empty, the nan() function will return the general NaN value.
The na() function returns a NaN value.
#include <iostream> #include <cmath> #include <cstring> using namespace std; int main() { double src = nan("1 uint64_t dest; //Copy the variable src to dest //Use <cstring> for memcpy() memcpy(&dest, &src, sizeof src); cout << "nan("1") = " << src << " (" << hex << dest << ")\n"; return 0; }
When the program is run, the output is:
nan("1") = nan (7ff8000000000001)