Rate This Document
Findability
Accuracy
Completeness
Readability

exp2

Compute the base-2 exponential of a real number.

Interface Definition

C interface:

float exp2f(float x);

double exp2(double x);

Fortran interface:

RES = EXP2F(X);

RES = EXP2(X);

Parameters

Parameter

Type

Description

Input/Output

x

  • For exp2f, x is of single-precision floating-point type.
  • For exp2, x is of double-precision floating-point type.

Floating-point value of the input data

Input

Return Value

  • The base-2 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 input of expf is greater than 128, the return value is +∞. If the input of exp is greater than 1024, the return value is +∞.
  • If the input of expf is less than -150, the return value is +0. If the input of exp is less than -1075, 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 = 1024.0; 
    // print result 
        printf("exp2(pi/2) = %.15f\n", exp2(x1)); 
        printf("exp2(2.0) = %.15f\n", exp2(x2)); 
        printf("exp2(1024.0) = %.15f\n", exp2(e)); 
        printf("exp2(0.0) = %.15f\n", exp2(a)); 
        printf("exp2(INFINITY) = %.15f\n", exp2(b)); 
        printf("exp2(-INFINITY) = %.15f\n", exp2(c)); 
        printf("exp2(NAN) = %.15f\n", exp2(d)); 
    /* 
     *  exp2(pi/2) = 2.970686423552019 
     *  exp2(2.0) = 4.000000000000000 
     *  exp2(710.0) = inf 
     *  exp2(0.0) = 1.000000000000000 
     *  exp2(INFINITY) = inf 
     *  exp2(-INFINITY) = 0.000000000000000 
     *  exp2(NAN) = nan 
     * 
     * */

Fortran interface:

    REAL(8) :: X = 2 
    PRINT*,  EXP2(X) 
    ! 
    ! OUTPUT 
    !     4.000000000000000 
    !