Rate This Document
Findability
Accuracy
Completeness
Readability

exp

Compute the base-e exponential of a real number.

Interface Definition

C interface:

float expf(float x);

double exp(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.

Floating-point value of the input data

Input

Return Value

  • The base-e exponential y 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.62e42ep6f (about 88), the return value is +∞. If the input of exp is greater than 0x1.62p9 (about 708), the return value is +∞.
  • If the input of expf is less than -0x1.9fe368p6f (about -104), the return value is +0. If the input value of exp is less than -0x1.62p9 (about -708), 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.

Dependencies

C: "km.h"

Fortran: "km.f03"

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 
    !