isunordered()函数检查是否可以将第一个参数的值与第二个参数进行有意义的比较。如果第一个参数不能与第二个参数进行有意义的比较(即一个或两个都是NAN),则返回1,否则返回0。
isunordered - 语法
bool isunordered(float x,float y); bool isunordered(double x,double y); bool isunordered(float x,float y); bool isunordered(Arithmetic x,Arithmetic y);
isunordered - 参数
(x,y):我们要比较的值。
isunordered - 返回值
如果一个或两个的值为NAN,则返回1,否则返回0。
isunordered - 例子1
让我们看一个简单的例子,当x的值为NAN时。
#include <iostream> #include<math.h> using namespace std; int main() { float x=sqrt(-2); float y=3.2; cout<<"Values of x and y are : "<<x<<","<<y<< ; cout<<"isunordered(x,y) : "<<isunordered(x,y); return 0; }
输出:
Values of x and y are : nan,3.2 isunordered(x,y) : 1
在此的示例x的值为NAN。因此,该函数返回1。
isunordered - 例子2
让我们看一个简单的例子
#include <iostream> #include<math.h> using namespace std; int main() { float x=2.6; float y=3.2; cout<<"Values of x and y are : "<<x<<","<<y<< ; cout<<"isunordered(x,y) : "<<isunordered(x,y); return 0; }
输出:
Values of x and y are : 2.6,3.2 isunordered(x,y) : 0
在此示例中,x和y都不是NAN。因此,该函数返回0值。