Calculates the exponential function of x (e raised to the power x where x is a double precision floating-point value).
Include
<math.h>
Prototype
long double expl(long double x);
Argument
x
Return Value
Returns the exponential of x
. On an overflow,
exp
returns inf
and on an underflow
exp
returns 0.
Remarks
A range error occurs if the magnitude of x
is too
large.
Example
#include <math.h>
#include <stdio.h>
#include <errno.h>
int main(void)
{
long double x, y;
errno = 0;
x = 1.0;
y = expl(x);
if (errno)
perror("Error");
printf("The exponential of %f is %f\n", x, y);
errno = 0;
x = 1E3;
y = expl(x);
if (errno)
perror("Error");
printf("The exponential of %f is %f\n", x, y);
errno = 0;
x = -1E3;
y = expl(x);
if (errno)
perror("Error");
printf("The exponential of %f is %f\n", x, y);
}
Example Output
The exponential of 1.000000 is 2.718282
Error: range error
The exponential of 1000.000000 is inf
Error: range error
The exponential of -1000.000000 is 0.000000