Commit | Line | Data |
---|---|---|
5d130d40 RM |
1 | /* |
2 | computes a^b. | |
3 | uses log and exp | |
4 | */ | |
5 | ||
6 | #include <errno.h> | |
7 | int errno; | |
8 | double log(), exp(); | |
9 | ||
10 | double | |
11 | pow(arg1,arg2) | |
12 | double arg1, arg2; | |
13 | { | |
14 | double temp; | |
15 | long l; | |
16 | ||
17 | if(arg1 <= 0.) { | |
18 | if(arg1 == 0.) { | |
19 | if(arg2 <= 0.) | |
20 | goto domain; | |
21 | return(0.); | |
22 | } | |
23 | l = arg2; | |
24 | if(l != arg2) | |
25 | goto domain; | |
26 | temp = exp(arg2 * log(-arg1)); | |
27 | if(l & 1) | |
28 | temp = -temp; | |
29 | return(temp); | |
30 | } | |
31 | return(exp(arg2 * log(arg1))); | |
32 | ||
33 | domain: | |
34 | errno = EDOM; | |
35 | return(0.); | |
36 | } |