Implementation status: partially implemented

Synopsis

#include <math.h>

double exp(double x);
float expf(float x);
long double expl(long double x);

Description

The functions compute the base-e exponential function of x, which is e raised to the power x: e^x.

Arguments:

x - the value of which base-e exponential function is computed.

An application wishing to check for error situations sets errno to zero and calls feclearexcept(FE_ALL_EXCEPT) before calling these functions. On return, if errno is non-zero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has occurred.

Return value

Upon successful completion, these functions return the exponential value of x.

If the correct value would cause overflow, a range error occurs and exp(), expf(), and expl() return the value of the macro HUGE_VAL, HUGE_VALF, and HUGE_VALL, respectively.

If the correct value causes underflow, and is not representable, a range error occurs, and exp(), expf(), and expl() return 0.0.

If x is NaN, a NaN is returned.

If x is ±0, 1 is returned.

If x is -Inf, +0 is returned.

If x is +Inf, x is returned.

If the correct value causes underflow, and is representable, a range error occurs and the correct value is returned.

Errors

[ERANGE] - the result overflows (overflow floating-point exception is raised) or
the result underflows (underflow floating-point exception is raised)

On error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling & MATH_ERREXCEPT) are independent of each other, but at least one of them must be non-zero.