C Standard Library

C <math.h> - isunordered()



The C <math.h> isunordered() macro returns true if one or both arguments are unordered value, else returns false. If one or both arguments are NaN, the arguments are unordered and thus cannot be meaningfully compared with each other.

Syntax

isunordered(x,y)              

Parameters

x Specify first floating point value.
y Specify second floating point value.

Return Value

Returns true (1) if one or both arguments are NaN, else returns false (0).

Example:

The example below shows the usage of isunordered() macro.

#include <stdio.h>
#include <math.h>
 
int main (){

  printf("isunordered(1.0, 2.0): %d\n", isunordered(1.0, 2.0));
  printf("isunordered(1.0, 1.0/0.0): %d\n", isunordered(1.0, 1.0/0.0));
  printf("isunordered(1.0, 0.0/0.0): %d\n", isunordered(1.0, 0.0/0.0));
  printf("isunordered(1.0, sqrt(-1.0)): %d\n", isunordered(1.0, sqrt(-1.0)));
  return 0;
}

The output of the above code will be:

isunordered(1.0, 2.0): 0
isunordered(1.0, 1.0/0.0): 0
isunordered(1.0, 0.0/0.0): 1
isunordered(1.0, sqrt(-1.0)): 1

❮ C <math.h> Library