std::nanf
STD:NaN,STD::NANF,STD::NUNL
Defined in header | | |
---|---|---|
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) |
转换实现定义的字符串。arg
转换为相应的静默NaN值,就像通过调用std::strtod
,,,std::strtof
,或std::strtold
分别如下:
打电话std::nan("string")
等于呼叫。std::strtod
("NAN(string)", (char**)nullptr..
.
打电话std::nan("")
等于呼叫。std::strtod
("NAN()", (char**)nullptr..
.
打电话std::nan(nullptr)
等于呼叫。std::strtod
("NAN", (char**)nullptr..
.
参数
arg | - | narrow character string identifying the contents of a NaN |
---|
返回值
对应于标识字符串的静默nan值。arg
如果实现不支持安静的NAN,则为零。
例
二次
#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 (C++11) | checks if the given number is NaN (function) |
---|---|
NAN (C++11) | evaluates to a quiet NaN of type float (macro constant) |
has_quiet_NaN static | identifies floating-point types that can represent the special value "quiet not-a-number" (NaN) (public static member constant of std::numeric_limits) |
has_signaling_NaN static | identifies floating-point types that can represent the special value "signaling not-a-number" (NaN) (public static member constant of std::numeric_limits) |
quiet_NaN static | returns a quiet NaN value of the given floating-point type (public static member function of std::numeric_limits) |
signaling_NaN static | returns a signaling NaN value of the given floating-point type (public static member function of std::numeric_limits) |
c NANF,NaN,NANL文件
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。