Math Isgreaterequal Function

The isgreaterequal function determines whether the value of first argument is greater or equal to the value of second argument. If the first argument is greater or equal to the second argument then it returns 1 otherwise 0.

Note: If one or both the arguments of a function are NAN then it returns 0.

Syntax

Consider two numbers 'x' and 'y'. Syntax would be:

Example

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 see a simple example when both x and y are of same type.

Example

#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:

Output

Values of x and y are: 8.7,7.7
isgreaterequal(x,y) :1

In this example, isgreaterequal function determines that the value of x is greater than y. Therefore, it returns 1.

Example 2

Let's see a simple example when both x and y are of different type.

Example

#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:

Output

Values of x and y are : 8.7,7
isgreaterequal(x,y) : 1

In this example, isgreaterequal function determines that the value of x is greater than y. Therefore, it returns 1.

Example 3

Let's see a simple example when the value of x is nan.

Example

#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:

Output

Values of x and y are : nan,8.0
isgreaterequal(x,y) : 0

In this example, the value of x is NAN. Therefore, the function returns 0.

Input Required

This code uses input(). Please provide values below: