exp() — Calculate Exponential Function

Format

#include <math.h>
double exp(double x);

Language Level: ANSI

Threadsafe: Yes.

Description

The exp() function calculates the exponential value of a floating-point argument x ( ex , where e equals 2.17128128...).

Return Value

If an overflow occurs, the exp() function returns HUGE_VAL. If an underflow occurs, it returns 0. Both overflow and underflow set errno to ERANGE. The value of errno can also be set to EDOM.

Example that uses exp()

This example calculates y as the exponential function of x:

#include <math.h>
#include <stdio.h>
 
int main(void)
{
   double x, y;
 
   x = 5.0;
   y = exp(x);
 
   printf("exp( %lf ) = %lf\n", x, y);
}
 
/*****************  Output should be similar to:  *****************
 
exp( 5.000000 ) = 148.413159
*/

Related Information



[ Top of Page | Previous Page | Next Page | Contents | Index ]