Namespaces
Variants

isless

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
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 isless(x, y) /* implementation defined */
(C99 起)

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

目录

参数

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

返回值

x < y 则返回非零整数值,否则返回 0

注释

浮点数的内置 operator < 在参数为 NaN 时可能抛出 FE_INVALID 。本函数是 operator < 的“静默”版本。

示例

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

可能的输出:

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

参考文献

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

参见

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