Math Isunordered Function - C++ Programming Tutorial
C++ Course / Math Functions / Math Isunordered Function

Math Isunordered Function

BLUF: Mastering Math Isunordered Function is a critical step in becoming a proficient C++ developer. This lesson provides a deep dive into the syntax, performance considerations, and real-world applications of this concept.
Key Performance Insight: Math Isunordered Function

C++ is renowned for its efficiency. Learn how Math Isunordered Function enables low-level control and high-performance computing in the tutorial below.

C++ Math isunordered

The isunordered function determines if the first argument can be compared with the second argument. If either value is NaN or if the comparison is not meaningful, it returns 1; otherwise, it returns 0.

Syntax

Consider two numerical values 'x' and 'y'. The syntax format is as follows:

Example

bool isunordered(float x,float y);
bool isunordered(double x,double y);
bool isunordered(float x,float y);
bool isunordered(Arithmetic x,Arithmetic y);

Parameter

(x,y) :The values which we want to compare.

Return value

If either one or both values are NaN, the function will return 1; otherwise, it will return 0.

Example 1

Let's examine a basic scenario where the value of x is not a number (NAN).

Example

#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<<'\n';
  cout<<"isunordered(x,y) : "<<isunordered(x,y);
  return 0;
}

Output:

Output

Values of x and y are : nan,3.2
isunordered(x,y) : 1

In this instance, the variable x is NaN. As a result, the method will output a value of 1.

Example 2

Let's see a simple example

Example

#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<<'\n';
  cout<<"isunordered(x,y) : "<<isunordered(x,y);
  return 0;
}

Output:

Output

Values of x and y are : 2.6,3.2
isunordered(x,y) : 0

In this instance, both x and y do not have a value of NAN. As a result, the function will output a value of 0.

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience