Namespaces
Variants

isunordered

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 isunordered(x, y) /* 由实现定义 */
(C99 起)

判断浮点数 x y 是否是无序的,即其中一个或两个为 NaN,因此无法进行有意义的相互比较。

目录

参数

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

返回值

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

示例

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

可能的输出:

isunordered(NAN,1.0) = 1
isunordered(1.0,NAN) = 1
isunordered(NAN,NAN) = 1
isunordered(1.0,0.0) = 0

参考文献

  • C23 标准 (ISO/IEC 9899:2024):
  • 7.12.14.6 isunordered 宏 (p: TBD)
  • F.10.11 比较宏 (p: TBD)
  • C17 标准 (ISO/IEC 9899:2018):
  • 7.12.14.6 isunordered 宏 (p: TBD)
  • F.10.11 比较宏 (p: TBD)
  • C11 标准 (ISO/IEC 9899:2011):
  • 7.12.14.6 isunordered 宏 (p: 261)
  • F.10.11 比较宏 (p: 531)
  • C99标准(ISO/IEC 9899:1999):
  • 7.12.14.6 isunordered宏(页码:242)

参见

对给定的浮点值进行分类
(函数宏)
(C99)
检查给定数值是否为 NaN
(函数宏)
C++ documentation for isunordered