C++ Math isgreater()

Last Updated : 16 May 2026

Math isgreater() Function

In C++, the isgreater() function is defined in the <cmath> or <math.h> header file and is used to determine whether the first argument is greater than the second argument. If the first value is greater than the second value, the function returns 1; otherwise, it returns 0.

The isgreater() function supports float, double, long double, and other arithmetic data types.

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

Syntax

It has the following syntax.

Note: The arithmetic type can be of any type. It can be either float, double, long double, int or char. If any parameter is integer type, then it is cast to double.

Parameters

x,y: The values which we want to compare.

Return value

Parameter(x,y)Return value
x>y1
x0

Examples of isgreater() Function

Here, we are going to discuss several examples to demonstrate the isgreater() Function.

Example 1: Compare Two Floating-Point Values Using isgreater()

This example demonstrates how the isgreater() function compares two floating-point values of the same type.

Output:

Values of x and y are : 9.0,7.0
isgreater(x,y) : 1

Explanation:

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

Example 2: Compare Values of Different Data Types Using isgreater()

This example demonstrates how the isgreater() function behaves when the values are of different data types.

Output:

Values of x and y are : 45.4,c
isgreater(x,y) : 0

Explanation:

In this example, isgreater() function determines that the value of x is less than y as the ASCII value of 'c' is greater than the value of x. Therefore, it returns 0.

Example 3: Compare a NaN Value Using isgreater()

This example demonstrates how the isgreater() function behaves when one of the values is NaN (Not a Number).

Output:

Values of x and y are : nan , 12.3
isgreater(x,y) : 0

Explanation:

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