C++ <cmath> - fmin() Function
The C++ <cmath> fmin() function returns minimum number between the two arguments. If one of the arguments is NaN, then the other argument is returned.
Syntax
double fmin (double x, double y); float fmin (float x, float y); long double fmin (long double x, long double y); double fmin (Type1 x, Type2 y);
Parameters
x |
Specify value to compare. |
y |
Specify value to compare. |
Return Value
Returns the numerically minimum value.
Example:
In the example below, 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:
50 5.5 -2 -3
❮ C++ <cmath> Library