| 1 |
#include "f2c.h" |
| 2 |
#ifdef __cplusplus |
| 3 |
extern "C" { |
| 4 |
#endif |
| 5 |
|
| 6 |
#ifdef KR_headers |
| 7 |
longint pow_qq(ap, bp) longint *ap, *bp; |
| 8 |
#else |
| 9 |
longint pow_qq(longint *ap, longint *bp) |
| 10 |
#endif |
| 11 |
{ |
| 12 |
longint pow, x, n; |
| 13 |
unsigned long long u; /* system-dependent */ |
| 14 |
|
| 15 |
x = *ap; |
| 16 |
n = *bp; |
| 17 |
|
| 18 |
if (n <= 0) { |
| 19 |
if (n == 0 || x == 1) |
| 20 |
return 1; |
| 21 |
if (x != -1) |
| 22 |
return x == 0 ? 1/x : 0; |
| 23 |
n = -n; |
| 24 |
} |
| 25 |
u = n; |
| 26 |
for(pow = 1; ; ) |
| 27 |
{ |
| 28 |
if(u & 01) |
| 29 |
pow *= x; |
| 30 |
if(u >>= 1) |
| 31 |
x *= x; |
| 32 |
else |
| 33 |
break; |
| 34 |
} |
| 35 |
return(pow); |
| 36 |
} |
| 37 |
#ifdef __cplusplus |
| 38 |
} |
| 39 |
#endif |