expm1(x)函数返回e 十、 –1,其中x是参数,e是数值等于2.71828的数学常数。
null
语法:
double expm1() (double x); float expm1() (float x); long double expm1() (long double x);
参数:
- expm1()函数接受一个参数并计算e^x-1。
返回:
- 如果我们在参数中传递x,函数的作用是:返回e^x-1。
- 必须同时给出两个参数,否则会出现错误 调用“expm1()”时没有匹配的函数 .
- 如果我们将字符串作为参数传递,我们将得到错误 调用“expm1”时没有匹配的函数(const char[n]) .
- 如果我们通过 标准::数值限制::最大值() 我们将得到-2147483648。
错误和异常:
例如:
Input : expm1(5.35) Output : 209.608
Input : expm1(-5) Output : -0.993262
#代码1
// CPP implementation of the // above function #include <cmath> #include <iostream> using namespace std; int main() { double x = 5.35, answer; answer = expm1(x); cout << "e^" << x << " - 1 = " << answer << endl; return 0; } |
输出:
e^5.35 - 1 = 209.608
#代码2
// CPP implementation of the // above function #include <cmath> #include <iostream> using namespace std; int main() { int x = -5; double answer; answer = expm1(x); cout << "e^" << x << " - 1 = " << answer << endl; return 0; } |
输出:
e^-5 - 1 = -0.993262
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END