exp() Calculate Exponential
#include <math.h>
double exp(x);
double x; Floating-point value
exp() returns the exponential function of 'x'.
Returns: Exponential function of 'x'. On overflow, matherr() is
called with an OVERFLOW error, set to ERANGE (defined in
<math.h>), and the value HUGE (defined in <math.h>) is
returned. On underflow 0.0 is returned. (matherr() is
not called on an underflow, and 'errno' is not set.)
Notes: Error handling can be modified by using the matherr()
routine.
OVERFLOW first occurs with 'x' greater than 7.0E2.
-------------------------------- Example ---------------------------------
The following statements continue printing the exponential function
of the values in an array until an OVERFLOW error occurs.
#include <math.h> /* for exp() and ERANGE */
#include <stdio.h> /* for printf() */
#include <stdlib.h> /* for errno */
/* the value 1000.0 will cause an error */
double values[6] = {0.0, 1.0, -1.0, -500, 1000.0, -0.2};
main()
{
double exponential;
int i;
errno = 0;
for (i = 0; !errno && i < 6; i++) {
exponential = exp(values[i]);
if (errno == ERANGE) /*an error is also printed to stderr */
printf("OVERFLOW error in exp()\n");
printf("exponential function of %f = %f\n",
values[i], exponential);
}
}
Seealso:
This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster