Facebook Page Twitter Page LinkedIn Page
× C++ Standard Library C++ STL Library

The C++ cmath fmin() function is used to return minimum number between the two arguments. If one of the arguments is NaN, then the other argument is returned.


double fmin (double x, double y);
float fmin (float x, float y);
long double fmin (long double x, long double y);
// additional overloads
double fmin (Type1 x, Type2 y);                             


x Specify value to compare.
y Specify value to compare.

Return Value

Returns the numerically minimum value.


In the below example, fmin() function is used to find out the minimum value between the two arguments.

#include <iostream>
#include <cmath>

using namespace std;
int main (){
  cout<<fmin(50, 100)<<"\n";
  cout<<fmin(5.5, 10.5)<<"\n";
  cout<<fmin(-2, 2)<<"\n"; 
  cout<<fmin(-3, -2)<<"\n";  
  return 0;

The output of the above code will be:


❮ C++ <cmath> Library