Namespaces
Variants

isgreaterequal

From cppreference.net
< c ‎ | numeric ‎ | math
Common mathematical functions
Functions
Basic operations
(C99)
(C99)
(C99)
(C99) (C99) (C99) (C23)
Maximum/minimum operations
Exponential functions
Power functions
Trigonometric and hyperbolic functions
Nearest integer floating-point
(C99) (C99) (C99)
(C23) (C23) (C23) (C23)
Floating-point manipulation
Narrowing operations
(C23)
(C23)
(C23)
(C23)
(C23)
(C23)
Quantum and quantum exponent
Decimal re-encoding functions
Total order and payload functions
Classification
isgreaterequal
(C99)
(C99)
(C23)

Error and gamma functions
(C99)
(C99)
(C99)
(C99)
Types
Macro constants
Special floating-point values
Arguments and return values
Error handling
Fast operation indicators
定义于头文件 <math.h>
#define isgreaterequal(x, y) /* 由实现定义 */
(C99 起)

判断浮点数 x 是否大于或等于浮点数 y ,且不触发浮点异常。

目录

参数

x - 浮点数值
y - 浮点数值

返回值

x >= y 则返回非零整数值, 0 表示其他情况。

注释

浮点数的内置 operator >= 在参数包含 NaN 时可能引发 FE_INVALID 。本函数是 operator >= 的"静默"版本。

示例

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

可能的输出:

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

参考文献

  • C23 标准 (ISO/IEC 9899:2024):
  • 7.12.14.2 isgreaterequal 宏 (p: TBD)
  • F.10.11 比较宏 (p: TBD)
  • C17 标准 (ISO/IEC 9899:2018):
  • 7.12.14.2 isgreaterequal 宏 (p: TBD)
  • F.10.11 比较宏 (p: TBD)
  • C11 标准 (ISO/IEC 9899:2011):
  • 7.12.14.2 isgreaterequal 宏 (p: 259-260)
  • F.10.11 比较宏 (p: 531)
  • C99标准(ISO/IEC 9899:1999):
  • 7.12.14.2 isgreaterequal宏(页码:240-241)

参见

检查第一个浮点参数是否小于或等于第二个
(函数宏)
C++ 文档 关于 isgreaterequal