The isgreaterequal function checks if the value of the first parameter is greater than or equal to the value of the second parameter. It will return 1 if the first parameter is greater or equal, otherwise it will return 0.
Note: If one or both the arguments of a function are NAN then it returns 0.
Syntax
Consider a pair of values 'x' and 'y'. The syntax is as follows:
bool isgreaterequal(float x, float y);
bool isgreaterequal(double x, double y);
bool isgreaterequal(long double x, long double y);
bool isgreaterequal(Arithmetic x, Arithmetic y);
Note: The arithmetic type can be of any type. It can be float, double, long double or int. If the type of any argument is integer then it is cast to double.
Parameter
(x,y) : The values which we want to compare.
Return value
| Parameter | Return value |
|---|---|
x>=y |
1 |
| x<=y or x = nan or y = nan | 0 |
Example 1
Let's examine a basic scenario where both variables x and y are of identical data type.
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
double x=8.7;
double y=7.7;
cout<<"Values of x and y are : "<<x<<","<<y<<'\n';
cout<<"isgreaterequal(x,y) : "<<isgreaterequal(x,y);
return 0;
}
Output:
Values of x and y are: 8.7,7.7
isgreaterequal(x,y) :1
In this instance, the isgreaterequal method assesses that the value of x surpasses y. As a result, it outputs a value of 1.
Example 2
Let's examine a basic scenario where both variables x and y have distinct data types.
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
double x=8.7;
int y=7;
cout<<"Values of x and y are : "<<x<<","<<y<<'\n';
cout<<"isgreaterequal(x,y) : "<<isgreaterequal(x,y);
return 0;
}
Output:
Values of x and y are : 8.7,7
isgreaterequal(x,y) : 1
In this instance, the isgreaterequal method establishes that the value of x exceeds y, resulting in a return value of 1.
Example 3
Let's explore a straightforward scenario where the value of x is NaN.
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
double x=0.0/0.0;
double y=8.0;
cout<<"Values of x and y are : "<<x<<","<<y<<'\n';
cout<<"isgreaterequal(x,y) : "<<isgreaterequal(x,y);
return 0;
}
Output:
Values of x and y are : nan,8.0
isgreaterequal(x,y) : 0
In this instance, x is evaluated as NaN, resulting in the function outputting 0.