|
|
1.1 root 1:
2:
3: exp() Mathematics Function exp()
4:
5:
6:
7:
8: Compute exponent
9:
10: #include <math.h>
11: ddoouubbllee eexxpp(_z) ddoouubbllee _z;
12:
13: eexxpp returns the exponential of _z, or _e^_z.
14:
15: ***** Example *****
16:
17: The following program prompts you for a number, then prints the
18: value for it as returned by exp, pow, log, and log10.
19:
20:
21: #include <math.h>
22: #include <stdio.h>
23: #define display(x) dodisplay((double)(x), #x)
24:
25:
26:
27: dodisplay(value, name)
28: double value; char *name;
29: {
30: if (errno)
31: perror(name);
32: else
33: printf("%10g %s\n", value, name);
34: errno = 0;
35: }
36:
37:
38:
39:
40: main()
41: {
42: extern char *gets();
43: double x;
44: char string[64];
45:
46:
47:
48: for(;;) {
49: printf("Enter number: ");
50: if(gets(string) == NULL)
51: break;
52: x = atof(string);
53:
54:
55:
56: display(x);
57: display(exp(x));
58: display(pow(10.0,x));
59: display(log(exp(x)));
60: display(log10(pow(10.0,x)));
61: }
62:
63:
64: COHERENT Lexicon Page 1
65:
66:
67:
68:
69: exp() Mathematics Function exp()
70:
71:
72:
73: }
74:
75:
76: ***** See Also *****
77:
78: errno, mathematics library
79:
80: ***** Diagnostics *****
81:
82: eexxpp indicates overflow by an eerrrrnnoo of EERRAANNGGEE and a huge returned
83: value.
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130: COHERENT Lexicon Page 2
131:
132:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.