📅  最后修改于: 2020-09-25 07:36:53             🧑  作者: Mango
double fdim(double x, double y);
float fdim(float x, float y);
long double fdim(long double x, long double y);
Promoted fdim(Type1 x, Type2 y); // For other combinations of arithmetic types.
从C++ 11开始,如果传递给fdim()的任何参数为long double
,则返回的Promoted
类型为long double
。如果不是,则返回类型Promoted
为double
。
此函数在
fdim() 函数采用两个浮点或整数类型的参数:
fdim() 函数返回:
#include
#include
using namespace std;
int main()
{
double x = 22.31, y = 13.17, result;
result = fdim(x, y);
cout << "fdim(x, y) = " << result << endl;
long double xLD = -22.31, resultLD;
y = 13.14;
resultLD = fdim(xLD, y);
cout << "fdim(xLD, y) = " << resultLD << endl;
return 0;
}
运行该程序时,输出为:
fdim(x, y) = 9.14
fdim(xLD, yLD) = 0