exp(3C)
_________________________________________________________________
exp $builtin function
Return the value of e raised to a given power.
_________________________________________________________________
Calling Sequence
double m, n, exp();
m = exp(n);
(or)
$builtin double exp();
double m, n;
m = exp(n);
where m and n are of type double.
Description
Use the exp function to find the value of the constant e, raised
to the power of the number you pass. The constant e has an
approximate value 2.718 and it is the base of the natural system
of logarithms.
The first version of the calling sequence noted above uses a
function call. The second might generate smaller or faster code,
but may not run under other C compilers.
The include file math.h defines this function and uses the
$builtin version. Using the include file will not cause any
portability problems.
Returns
If floating-point overflow or underflow occurs, this function
returns the largest possible floating-point number and sets errno
to ERANGE (defined in errno.h).
Related Functions
See also the frexp, ldexp, log, log10, and scale10 functions.
Example
/* Program test for the exp() function */
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
exp(3C)
#include <math.h>
int i = 1;
double m, n, atof(), exp();
main(argc, argv)
int argc;
char *argv[];
{
while (i < argc) {
n = atof(argv[i]);
printf("Value of e to the power of %f = %f\n",
n, m = exp(n));
i++;
}
}
If you call the program test with the input numbers
1
2.718281
3.14159
you generate the output
Value of e to the power of 1.000000 = 2.718282
Value of e to the power of 2.718281 = 15.154250
Value of e to the power of 3.141590 = 23.140631
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)