exp2
Return the value of 2 raised to the power of x.
Interface Definition
C interface:
float exp2f(float x);
double exp2(double x);
long double exp2l(long double x);
Fortran interface:
RES = EXP2F(X);
RES = EXP2(X);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of the input data. |
Input |
Return Value
- The result y of 2 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 input of exp2f is greater than 128, the return value is +∞. If the input of exp2 is greater than or equal to 1024, the return value is +∞.
- If the input of exp2f is less than -150, the return value is +0. If the input of exp2 is less than or equal to -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"
Examples
C interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | double pi = acos(-1); // typical usage double x1 = pi/2, x2 = 2.0; // special handling 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(1024.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
!
Parent topic: Exponential and Logarithmic Functions