exp2, exp2f, exp2l

Computes 2 raised to the specified value.

Syntax

double exp2(
   double x
);

float exp2(
   float x
);  // C++ only

long double exp2(
   long double x
); // C++ only

float exp2f(
   float x
);

long double exp2l(
   long double x
);

Parameters

x
The value of the exponent.

Return Value

If successful, returns the base-2 exponent of x, that is, 2x. Otherwise, it returns one of the following values:

Issue Return
x = ±0 1
x = -INFINITY +0
x = +INFINITY +INFINITY
x = NaN NaN
Overflow range error +HUGE_VAL, +HUGE_VALF, or +HUGE_VALL
Underflow range error Correct result, after rounding

Errors are reported as specified in _matherr.

Remarks

Because C++ allows overloading, you can call overloads of exp2 that take and return float and long double types. In a C program, exp2 always takes and returns a double.

Requirements

Routine C header C++ header
exp, expf, expl <math.h> <cmath>

For additional compatibility information, see Compatibility.

See also

Alphabetical Function Reference
exp, expf, expl
log2, log2f, log2l