Introduction
The value of the first argument is meaningfully checked with the second argument by the isunordered() function. If the first argument can not be compared with the second argument, the program will return 1; otherwise, 0. The isunordered() function is a library function in the header file cmath and checks whether the given values are unordered, i.e., if one or both values are Not-A-Number (NaN).
Parameters: It will take two values, x, and y, i.e., the values, to check whether they are unordered or not.
Returns: It will return 1 when the value of x or y is NAN. Otherwise, it will return 0.
Syntax
bool isunordered(float x, float y)
bool isunordered(double x, double y)
The isunordered() function will take two values as input and test if they are unordered or not. It returns 1 if either or both of the two values is NAN, or else it returns 0.
Also see, Literals in C, Fibonacci Series in C++
Example
Code
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
float x = 12.0;
float y = sqrt(-12.0);
cout << "x is " << x << endl;
cout << "y is " << y << endl;
if(isunordered(x, y) == 1)
{
cout << "x and y are unordered\n";
}
else
{
cout << "x and y are not unordered\n";
}
return 0;
}
Output
x is 12
y is -nan
x and y are unordered
Explanation
The isunordered() function takes two values x and y where x= 12.0 and y=sqrt(-12.0) as input and tests if they are unordered. It returns 1 if either or both of the two values is NAN otherwise it returns 0.
Try and compile with online c++ compiler.