isunordered
宏 <cmath> <ctgmath>
C99 |
macro: isunordered(x, y) |
C++11 |
function:
bool isunordered (float x, float y);
bool isunordered (double x, double y);
bool isunordered (long double x, long double y); |
是否是无序的
返回x或y是否为无序值:
如果一个或两个参数都是NaN,则参数是无序的,函数返回true。在任何情况下,函数都不会引发
FE_INVALID异常。
C99 |
在C语言中,它被实现为一个返回int值的宏。x和y的类型都应该是float, double或long double。 |
C++11 |
在c++中,它是通过对每个浮点类型的函数重载来实现的,每个类型返回一个bool值。 |
☲ 参数
x, y
用来检查是否无序的值。
☉ 返回值
如果x或y是NaN,则为true(1)。,否则为假(0).
☣ 示例
/* isunordered example */
#include <stdio.h> /* printf */
#include <math.h> /* isunordered, sqrt */
int main ()
{
double result;
result = sqrt (-1.0);
if (isunordered(result,0.0))
printf ("sqrt(-1.0) and 0.0 cannot be ordered");
else
printf ("sqrt(-1.0) and 0.0 can be ordered");
return 0;
}
|
输出:
sqrt(-1.0) and 0.0 cannot be ordered
🍄 另请参阅