function
<cmath> <ctgmath>

exp

double exp (double x);
     double exp  (double x);      float expf (float x);long double expl (long double x);
     double exp (double x);      float exp (float x);long double exp (long double x);
     double exp (double x);      float exp (float x);long double exp (long double x);     double exp (T x);           // additional overloads for integral types
Compute exponential function
Returns the base-e exponential function of x, which is e raised to the power x: ex.

Header <tgmath.h> provides a type-generic macro version of this function.
This function is overloaded in <complex> and <valarray> (see complex exp and valarray exp).
Additional overloads are provided in this header (<cmath>) for the integral types: These overloads effectively cast x to a double before calculations.

This function is also overloaded in <complex> and <valarray> (see complex exp and valarray exp).

Parameters

x
Value of the exponent.

Return Value

Exponential value of x.
If the magnitude of the result is too large to be represented by a value of the return type, the function returns HUGE_VAL (or HUGE_VALF or HUGE_VALL) with the proper sign, and an overflow range error occurs:

If an overflow range error occurs, the global variable errno is set to ERANGE.
If an overflow range error occurs:
- And math_errhandling has MATH_ERRNO set: the global variable errno is set to ERANGE.
- And math_errhandling has MATH_ERREXCEPT set: FE_OVERFLOW is raised.

Example

1
2
3
4
5
6
7
8
9
10
11
12
/* 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;
}

Output:

The exponential value of 5.000000 is 148.413159.


See also