C++ cmath islessgreater


int islessgreater(float x , float y);
int islessgreater(double x , double y);
int islessgreater(long double x, long double y);

The C++ <cmath> islessgreater determines if the first argument is less than or greater than the second argument.

Parameters:
x -The first argument.

y -The second argument.

Return type
int -Return the value of ‘(x) < (y) || (x) > (y)‘.

Some points to note:

 i) The value of islessgreater(x , y) is same as (x) < (y) || (x) > (y).The only difference between them is unlike ‘(x) < (y) || (x) > (y)’, islessgreater(x, y) does not raise the ‘invalid’ floating-point exception when x and y are unordered.

 ii) +∞ is treated as greater than any valid value,-∞ is treated as smaller than any valid value.

 iii) If one of the arguments is NaN ,0 is always returned.

 iv) If character or int type is passed as argument the function with double as parameter type is called.

Code example

cout<< “islessgreater(101 , 100)=” << islessgreater(101 , 100) << endl;

/*Passing INFINITY */
cout<< “islessgreater(INFINITY , INFINITY)=” << islessgreater(INFINITY , INFINITY) << endl;

/*Passing NaN */
cout<< “islessgreater(-NAN , 0)=” << islessgreater(-NAN , 0) << endl ;

Output

islessgreater(101 , 100)= 1
islessgreater(INFINITY , INFINITY)= 0
islessgreater(-NAN , 0)= 0


Related links

->C++ islessequal>

->C++ isgreaterequal>