📅  最后修改于: 2020-09-25 07:40:05             🧑  作者: Mango
该函数在
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
从C++ 11开始,如果传递给fmin()的任何参数为long double
,则返回类型Promoted
为long double
。如果不是,则返回类型Promoted
为double
。
fmin() 函数返回x和y中的最小值。
#include
#include
using namespace std;
int main()
{
double x = -2.05, y = NAN, result;
result = fmin(x, y);
cout << "fmin(x, y) = " << result << endl;
return 0;
}
运行该程序时,输出为:
fmin(x, y) = -2.05
#include
#include
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;
}
运行该程序时,输出为:
fmin(x, y) = 56.13