isnan、 、 _isnan_isnanf

測試浮點值是否為 NaN(「不是數位」)。

語法

int isnan(
   /* floating-point */ x
); /* C-only macro */

int _isnan(
   double x
);

int _isnanf(
   float x
); /* x64 only */

template <class T>
bool isnan(
   T x
) throw(); /* C++ only */

參數

x
要測試的浮點值。

傳回值

在 C 中isnan,如果自變數x是 NaN,則巨集 和函_isnan_isnanf式會傳回非零值,否則會傳回 0。

在C++中,如果自變數x是 NaN,則isnan樣板函式會傳回 true ,否則會傳false回 。

備註

因為 NaN 值不會與本身或任何其他 NaN 值相比較,因此若要偵測其中一個值,您必須使用下列其中一個函式或宏。 當指定的類型無法以 IEEE-754 浮點格式表示浮點運算的結果時,會產生 NaN。 如需 NaN 如何代表輸出的資訊,請參閱 printf

當編譯為C++時, isnan 不會定義巨集,而是 isnan 定義範本函式。 其行為方式與巨集相同,但會傳回型 bool 別的值,而不是整數。

_isnanf_isnan式Microsoft特定。 _isnanf 函式只適用於 x64 編譯時。

需求

常式 必要的標頭 (C) 必要的標頭 (C++)
isnan, _isnanf <math.h> <math.h> 或 <cmath>
_isnan <float.h> <float.h> 或 <cfloat>

如需相容性詳細資訊,請參閱相容性

另請參閱

數學與浮點支援
fpclassify
_fpclass, _fpclassf
isfinite、 、 _finite_finitef
isinf
isnormal