Commit | Line | Data |
---|---|---|
547779a8 WH |
1 | #include "f2c.h" |
2 | ||
3 | #ifdef KR_headers | |
4 | longint pow_qq(ap, bp) longint *ap, *bp; | |
5 | #else | |
6 | longint pow_qq(longint *ap, longint *bp) | |
7 | #endif | |
8 | { | |
9 | longint pow, x, n; | |
10 | ||
11 | x = *ap; | |
12 | n = *bp; | |
13 | ||
14 | if (n <= 0) { | |
15 | if (n == 0 || x == 1) | |
16 | return 1; | |
17 | if (x != -1) | |
18 | return x == 0 ? 1/x : 0; | |
19 | n = -n; | |
20 | } | |
21 | for(pow = 1; ; ) | |
22 | { | |
23 | if(n & 01) | |
24 | pow *= x; | |
25 | if(n >>= 1) | |
26 | x *= x; | |
27 | else | |
28 | break; | |
29 | } | |
30 | return(pow); | |
31 | } |