# exp2f Function

Calculates the base 2 exponential function of x (2x, where x is a single precision floating-point value).

Include

<math.h>

Prototype

float exp2f(float x);

Argument

 x value for which to return the exponential

Return Value

Returns 2x.

Remarks

A range error occurs if the magnitude of x is too large, and errno will be set to ERANGE.

Example

See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

#include <math.h>
#include <stdio.h>
#include <errno.h>

int main(void)
{
float x, y;

errno = 0;
x = 1.0;
y = exp2f(x);
if (errno)
perror("Error");
printf("The base 2 exponential of %f is %f\n", x, y);

errno = 0;
x = 10;
y = exp2f(x);
if (errno)
perror("Error");
printf("The base 2 exponential of %f is %f\n", x, y);

errno = 0;
x = -10;
y = exp2f(x);
if (errno)
perror("Error");
printf("The base 2 exponential of %f is %f\n", x, y);
}

Example Output

The base 2 exponential of 1.000000 is 2.000000
The base 2 exponential of 10.000000 is 1024.000000
The base 2 exponential of -10.000000 is 0.000977