©
本文檔使用php中文網手册發布
|
在头文件 |
|
|
|---|---|---|
|
float nanf( const char* arg ); |
|
(since C99) |
|
double nan( const char* arg ); |
|
(since C99) |
|
long double nanl( const char* arg ); |
|
(since C99) |
实现定义字符串转换arg成相应的静态NaN值,则通过调用strtof,strtod或者strtold,分别说明如下:
通话nan("string")等同于通话strtod("NAN(string)", (char**)NULL);。
实现定义字符串转换arg成相应的静态NaN值,则通过调用strtof,strtod或者strtold,分别说明如下:
通话nan("string")等同于通话strtod("NAN(string)", (char**)NULL);。
通话nan("")等同于通话strtod("NAN()", (char**)NULL);。
通话nan(NULL)等同于通话strtod("NAN", (char**)NULL);。
|
arg |
- |
窄字符串标识NaN的内容 |
|---|
#include#include #include #include #include int main(void){ double f1 = nan("1"); uint64_t f1n; memcpy(&f1n, &f1, sizeof f1); printf("nan(\"1\") = %f (%" PRIx64 ")\n", f1, f1n); double f2 = nan("2"); uint64_t f2n; memcpy(&f2n, &f2, sizeof f2); printf("nan(\"2\") = %f (%" PRIx64 ")\n", f2, f2n); double f3 = nan("0xF"); uint64_t f3n; memcpy(&f3n, &f3, sizeof f3); printf("nan(\"0xF\") = %f (%" PRIx64 ")\n", f3, f3n);}