Home C&C++函数库 c++ 语法 程序源码 Linux C库

exp

函数  <cmath> <ctgmath>

C90 double exp (double x);
C99 double exp (double x);
float expf (float x);
long double expl (long double x);
C++98 double exp (double x);
float exp (float x);
long double exp (long double x);
C++11 double exp (double x);
float exp (float x);
long double exp (long double x);
double exp (T x);        // additional overloads for integral types

指数函数
返回以e为底数x为指数的函数,即e的x次方:ex
C99 头文件<tgmath.h> 提供了该函数的泛型类型宏版本。
C++98 这个函数在<complex>和<valarray> 中重载(参见complex exp和valarray exp)。
C++11 这个头文件(<cmath>) 为整型提供了额外的重载:这些重载在计算之前将x转换为double.
这个函数在<complex>和<valarray> 中也重载(参见complex exp和valarray exp)。

☲  参数


x
指数的值。

☉  返回值



x为指数的值。 如果结果的值太大而不能用返回类型的值表示,则函数返回带有正确符号的HUGE_VAL (或HUGE_VALFHUGE_VALF或 HUGE_VALL), 并发生范围溢出错误:
C90(C++98) 如果发生范围溢出错误,全局变量errno将被设置为ERANGE。
C99(C++11) 如果出现范围溢出错误:
-并且math_errhandling设置了MATH_ERRNO: 全局变量errno设置为ERANGE.
-并且math_errhandling设置了MATH_ERREXCEPT: 触发 FE_OVERFLOW .

☣  示例



/* exp example */
#include <stdio.h>      /* printf */
#include <math.h>       /* exp */

int main ()
{
  double param, result;
  param = 5.0;
  result = exp (param);
  printf ("The exponential value of %f is %f.\n", param, result );
  return 0;
}

输出:
The exponential value of 5.000000 is 148.413159.

🍄  另请参阅



log 计算自然对数(function )
pow 次幂(function )

联系我们 免责声明 关于CandCplus 网站地图