Rate This Document
Findability
Accuracy
Completeness
Readability

exp

Return the value of e raised to the power of x.

Interface Definition

C interface:

float expf(float x);

double exp(double x);

long double expl(long double x);

Fortran interface:

RES = EXPF(X);

RES = EXP(X);

Parameters

Parameter

Type

Description

Input/Output

x

  • For expf, x is of single-precision floating-point type.
  • For exp, x is of double-precision floating-point type.
  • For expl, x is of long double-precision floating-point type.

Floating-point value of the input data.

Input

Return Value

  • The result y of e raised to the power of x is returned. y ∈ (0, +INF)
  • If the input is +0, the return value is +1.
  • If the input is -0, the return value is -1.
  • If the input of expf is greater than 0x1.62e42ep6 (about 88.72), the return value is +∞. If the input of exp is greater than or equal to 0x1p10 (1024), the return value is +∞.
  • If the input of expf is less than -0x1.9fe368p6 (about -103.97), the return value is +0. If the input of exp is less than or equal to -0x1p10 (-1024), the return value is +0.
  • If the input is +∞, the return value is +∞.
  • If the input is -∞, the return value is +0.
  • If the input is NaN, the return value is NaN.

Dependency

C: "km.h"

Examples

C interface:

    double pi = acos(-1); 
    // typical usage 
    double x1 = pi/2, x2 = 2.0; 
    // special handing 
    double a = 0.0, b = INFINITY, c = -INFINITY, d = NAN, e = 710.0; 
    // print result 
    printf("exp(pi/2) = %.15f\n", exp(x1)); 
    printf("exp(2.0) = %.15f\n", exp(x2)); 
    printf("exp(710.0) = %.15f\n", exp(e)); 
    printf("exp(0.0) = %.15f\n", exp(a)); 
    printf("exp(INFINITY) = %.15f\n", exp(b)); 
    printf("exp(-INFINITY) = %.15f\n", exp(c)); 
    printf("exp(NAN) = %.15f\n", exp(d)); 
    /* 
     *  exp(pi/2) = 4.810477380965351 
     *  exp(2.0) = 7.389056098930650 
     *  exp(710.0) = inf 
     *  exp(0.0) = 1.000000000000000 
     *  exp(INFINITY) = inf 
     *  exp(-INFINITY) = 0.000000000000000 
     *  exp(NAN) = nan 
     * 
     * */

Fortran interface:

    REAL(8) :: X = 2 
    PRINT*,  EXP(X) 
    ! 
    ! OUTPUT 
    !     7.389056098930650 
    !