Returns whether x or y are unordered values.
The C99 prototype is listed as follows.
macro isunordered(x,y)
The C++11 prototype is listed as follows.
bool isunordered (float x , float y); bool isunordered (double x , double y); bool isunordered (long double x, long double y);
This function has the following parameter.
true 1 if either x or y is NaN. false 0 otherwise.
#include <stdio.h> /* printf */
#include <math.h> /* isunordered, sqrt */
/*w w w. ja v a 2s . com*/
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;
}
The code above generates the following result.
#include <stdio.h>
#include <math.h>
/* w ww . ja v a 2 s . com*/
int main(void){
printf("isunordered(NAN,1.0) = %d\n", isunordered(NAN,1.0));
printf("isunordered(1.0,NAN) = %d\n", isunordered(1.0,NAN));
printf("isunordered(NAN,NAN) = %d\n", isunordered(NAN,NAN));
printf("isunordered(1.0,0.0) = %d\n", isunordered(1.0,0.0));
return 0;
}
The code above generates the following result.