exp() Mathematics Function exp() Compute exponent #include <math.h> double exp(z) double z; exp returns the exponential of z, or e^z. ***** Example ***** The following program prompts you for a number, then prints the value for it as returned by exp, pow, log, and log10. #include <math.h> #include <stdio.h> #define display(x) dodisplay((double)(x), #x) dodisplay(value, name) double value; char *name; { if (errno) perror(name); else printf("%10g %s\n", value, name); errno = 0; } main() { extern char *gets(); double x; char string[64]; for(;;) { printf("Enter number: "); if(gets(string) == NULL) break; x = atof(string); display(x); display(exp(x)); display(pow(10.0,x)); display(log(exp(x))); display(log10(pow(10.0,x))); } COHERENT Lexicon Page 1
exp() Mathematics Function exp() } ***** See Also ***** errno, mathematics library ***** Diagnostics ***** exp indicates overflow by an errno of ERANGE and a huge returned value. COHERENT Lexicon Page 2