C++ Standard Library C++ STL Library

C++ <cmath> - isless() Function



The C++ <cmath> isless() function returns true if the first argument is less than 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 isless (float x, float y);
bool isless (double x, double y);
bool isless (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 the second argument, else returns false (0).

Example:

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

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

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

  return 0;
}

The output of the above code will be:

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

❮ C++ <cmath> Library