COHERENT manpages
This page displays the COHERENT manpage for exp() [Compute exponent].
List of available manpages
Index
exp() -- Mathematics Function (libm)
Compute exponent
#include <math.h>
double exp(z) double z;
exp() returns the exponential of z, or e^z.
Example
The following example, called apr.c, computes the annual percentage rate
(APR) for a given rate of interest. Compile it with the command:
cc -f apr.c -lm
It is by Brent Seidel (brent_seidel@chthone.stat.com):
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
main()
{
double rate, APR;
char buffer[50];
printf("Enter interest rate in percent (e.g., 12.9): ");
fflush(stdout);
if (gets(buffer) == NULL)
exit(EXIT_FAILURE);
rate = strtod(buffer);
APR = (exp(rate/100.0) - 1) * 100.0;
printf("The APR for %g%% compounded daily is %g%%\n", rate, APR);
}
See Also
errno,
frexp(),
ldexp(),
libm
ANSI Standard, §7.5.4.1
POSIX Standard, §8.1
Diagnostics
exp() indicates overflow by an errno of ERANGE and a huge returned value.