Commit | Line | Data |
---|---|---|
15eea6e6 BJ |
1 | float pow_ri(ap, bp) |
2 | float *ap; | |
3 | long int *bp; | |
4 | { | |
5 | double pow, x; | |
6 | long int n; | |
7 | ||
8 | pow = 1; | |
9 | x = *ap; | |
10 | n = *bp; | |
11 | ||
12 | if(n != 0) | |
13 | { | |
14 | if(n < 0) | |
15 | { | |
16 | if(x == 0) | |
17 | { | |
18 | return(pow); | |
19 | } | |
20 | n = -n; | |
21 | x = 1/x; | |
22 | } | |
23 | for( ; ; ) | |
24 | { | |
25 | if(n & 01) | |
26 | pow *= x; | |
27 | if(n >>= 1) | |
28 | x *= x; | |
29 | else | |
30 | break; | |
31 | } | |
32 | } | |
33 | return(pow); | |
34 | } |