English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C ++adopts two parameters and returns the minimum parameter among them. If one of the parameters is NAN, it returns the other parameter.
The function in<cmath>defined in the header file.
double fmin(double x, double y); float fmin(float x, float y); long double fmin(long double x, long double y); Promoted fmin(Type1 x, Type2 y); // Additional overloads for arithmetic types
From C ++ 11Starting from C, if the parameters passed to fmin() are of type long double, the returned type Promoted is long double. If not, the returned type Promoted is double.
x: The first parameter of fmin().
y: The second parameter of fmin().
The fmin() function returns the minimum value between x and y.
#include <iostream> #include <cmath> using namespace std; int main() { double x = -2.05, y = NAN, result; result = fmin(x, y); cout << "fmin(x, y) = " << result << endl; return 0; }
When running the program, the output is:
fmin(x, y) = -2.05
#include <iostream> #include <cmath> using namespace std; int main() { double x = 56.13, result; int y = 89; result = fmin(x, y); cout << "fmin(x, y) = " << result << endl; return 0; }
When running the program, the output is:
fmin(x, y) = 56.13