signbit

确定浮点值是否为负数。

语法

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

inline bool signbit(
   float x
) throw(); /* C++-only overloaded function */

inline bool signbit(
   double x
) throw(); /* C++-only overloaded function */

inline bool signbit(
   long double x
) throw(); /* C++-only overloaded function */

参数

x
要测试的浮点值。

返回值

如果参数 x 为负或负无穷大,则 signbit 返回非零值(在 C++ 中则返回 true)。 如果参数是非负数、正无穷大或 NAN,则返回 0(在 C++ 中返回 false)。

备注

当编译为 C 时,signbit 是一个宏,而当编译为 C++ 时,它是一个重载的内联函数。

要求

功能 必需的标头 (C) 必需的标头 (C++)
signbit <math.h> <math.h> 或 <cmath>

有关兼容性的详细信息,请参阅 兼容性

另请参阅

数学和浮点支持
isfinite_finite_finitef
isinf
isnan_isnan_isnanf
isnormal
_fpclass_fpclassf