isgreater

< c‎ | numeric‎ | math
在标头 <math.h> 定义
#define isgreater(x, y) /* 由实现定义 */
(C99 起)

确定浮点数 x 是否大于浮点数 y,而不设置浮点异常。

参数

x - 浮点值
y - 浮点值

返回值

x > y 则为非零整数值,否则为 0

注解

若一或两个参数为 NaN,则内建的 operator> 对浮点数可能引发 FE_INVALID。此宏是 operator> 的“安静”版本。

示例

#include <math.h>
#include <stdio.h>
 
int main(void)
{
    printf("isgreater(2.0,1.0)      = %d\n", isgreater(2.0, 1.0));
    printf("isgreater(1.0,2.0)      = %d\n", isgreater(1.0, 2.0));
    printf("isgreater(INFINITY,1.0) = %d\n", isgreater(INFINITY, 1.0));
    printf("isgreater(1.0,NAN)      = %d\n", isgreater(1.0, NAN));
 
    return 0;
}

可能的输出:

isgreater(2.0,1.0)      = 1
isgreater(1.0,2.0)      = 0
isgreater(INFINITY,1.0) = 1
isgreater(1.0,NAN)      = 0

引用

  • C23 标准(ISO/IEC 9899:2024):
  • 7.12.14.1 The isgreater macro (第 TBD 页)
  • F.10.11 Comparison macros (第 TBD 页)
  • C17 标准(ISO/IEC 9899:2018):
  • 7.12.14.1 The isgreater macro (第 189 页)
  • F.10.11 Comparison macros (第 386-387 页)
  • C11 标准(ISO/IEC 9899:2011):
  • 7.12.14.1 The isgreater macro (第 259 页)
  • F.10.11 Comparison macros (第 531 页)
  • C99 标准(ISO/IEC 9899:1999):
  • 7.12.14.1 The isgreater macro (第 240 页)

参阅

(C99)
检查第一个浮点实参是否小于第二个
(宏函数)