macro
<cmath> <ctgmath>

isunordered

macro
isunordered(x,y)
function
bool isunordered (float x      , float y);bool isunordered (double x     , double y);bool isunordered (long double x, long double y);
Is unordered
Returns whether x or y are unordered values:

If one or both arguments are NaN, the arguments are unordered and the function returns true. In no case the function raises a FE_INVALID exception.

In C, this is implemented as a macro that returns an int value. The type of both x and y shall be float, double or long double.
In C++, it is implemented with function overloads for each floating-point type, each returning a bool value.

Parameters

x, y
Values to check whether they are unordered.

Return value

true (1) if either x or y is NaN.
false (0) otherwise.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* 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;
}

Output:

sqrt(-1.0) and 0.0 cannot be ordered


See also