isgreater, isgreaterequal, isless, islessequal, islessgreater, isunordered

确定两个浮点值之间的排序关系。

语法

int isgreater(
   /* floating-point */ x,
   /* floating-point */ y
); /* C-only macro */

int isgreaterequal(
   /* floating-point */ x,
   /* floating-point */ y
); /* C-only macro */

int isless(
   /* floating-point */ x,
   /* floating-point */ y
); /* C-only macro */

int islessequal(
   /* floating-point */ x,
   /* floating-point */ y
); /* C-only macro */

int islessgreater(
   /* floating-point */ x,
   /* floating-point */ y
); /* C-only macro */

int isunordered(
   /* floating-point */ x,
   /* floating-point */ y
); /* C-only macro */
template <class FloatingType1, class FloatingType2>
inline bool isgreater(
   FloatingType1 x,
   FloatingType2 y
) throw(); /* C++-only template function */

template <class FloatingType1, class FloatingType2>
inline bool isgreaterequal(
   FloatingType1 x,
   FloatingType2 y
) throw(); /* C++-only template function */

template <class FloatingType1, class FloatingType2>
inline bool isless(
   FloatingType1 x,
   FloatingType2 y
) throw(); /* C++-only template function */

template <class FloatingType1, class FloatingType2>
inline bool islessequal(
   FloatingType1 x,
   FloatingType2 y
) throw(); /* C++-only template function */

template <class FloatingType1, class FloatingType2>
inline bool islessgreater(
   FloatingType1 x,
   FloatingType2 y
) throw(); /* C++-only template function */

template <class FloatingType1, class FloatingType2>
inline bool isunordered(
   FloatingType1 x,
   FloatingType2 y
) throw(); /* C++-only template function */

参数

xy
要比较的浮点值。

返回值

在所有比较中,同一个符号的无穷是相等的。 负无穷小于任何有限值或正无穷。 正无穷大于任何有限值或负无穷。 无论符号如何,零都相等。 NaN 不能小于、等于或大于任何值,包括另一个 NaN。

当两个参数都不是 NaN 时,如果 xy 之间的指定排序关系为 true,则排序宏 isgreaterisgreaterequalislessislessequal 将返回一个非零值。 如果其中一个或两个参数均为 NaN,或者排序关系为 false,则这些宏返回 0。 函数形式的行为方式相同,但返回 truefalse

如果 xy 都不是 NaN,并且 x 小于或大于 y,则 islessgreater 宏将返回一个非零值。 如果其中一个或两个参数均为 NaN,或者两个值相等,则返回 0。 函数形式的行为方式相同,但返回 truefalse

如果 x 和/或 y 为 NaN,则 isunordered 宏将返回非零值。 否则,返回 0。 函数形式的行为方式相同,但返回 truefalse

备注

这些比较运算在编译为 C 时作为宏实现,在编译为 C++ 时作为内联模板函数实现。

要求

函数 必需的标头 (C) 必需的标头 (C++)
isgreater, isgreaterequal, isless,
islessequal, islessgreater, isunordered
<math.h> <math.h> 或 <cmath>

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

另请参阅

数学和浮点支持
isfinite_finite_finitef
isinf
isnan_isnan_isnanf
_fpclass_fpclassf