C++ Math islessequal()

Last Updated : 22 May 2026

Math islessequal() Function

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

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

Note: If one or both the arguments are NAN then the function returns false(0).

Syntax

It has the following syntax.

Parameters

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

Return value

Parameter(x,y)Return value
x<=y1
x>y or x=nan or y=nan0

Examples of islessequal() () Function

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

Example 1: Compare Two Values of the Same Data Type Using islessequal()

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

Output:

Values of x and y are : 3.4,3.4
islessequal(x,y) : 1

Explanation:

In this example, islessequal() function determines that both x and y are equal. Therefore, it returns 1.

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

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

Output:

 Values of x and y are : 7.8,2
 islessequal(x,y) : 0

Explanation:

In this example, x is greater than y. Therefore, the function returns 0.

Example 3: Compare NaN Values Using islessequal()

This example demonstrates how the islessequal() function behaves when one or both values are NaN (Not a Number).

Output:

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

Explanation:

In this example, both x and y are NAN. Therefore, the function returns 0.