C++ Standard Library C++ STL Library

C++ <cmath> - islessequal() Function



The C++ <cmath> islessequal() function returns true if the first argument is less than or equal to the second argument, else returns false. If any of the arguments is NaN, the function returns false, and no FE_INVALID exception is raised but using <= operator may raise such exception.

Syntax

bool islessequal (float x, float y);
bool islessequal (double x, double y);
bool islessequal (long double x, long double y);                  

Parameters

x Specify first value to be compared.
y Specify second value to be compared.

Return Value

Returns true (1) if the first argument is less than or equal to the second argument, else returns false (0).

Example:

The example below shows the usage of islessequal() function.

#include <iostream>
#include <cmath>
using namespace std;
 
int main (){
  int x = 10;
  int y = 50;
  int z = 10;

  cout<<boolalpha;
  cout<<"x <= y: "<<islessequal(x, y);
  cout<<endl;
  cout<<"x <= z: "<<islessequal(x, z);
  cout<<endl;
  cout<<"y <= z: "<<islessequal(y, z);

  return 0;
}

The output of the above code will be:

x <= y: true
x <= z: true
y <= z: false

❮ C++ <cmath> Library