|
Last change
on this file since 410 was 2, checked in by bird, 23 years ago |
|
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
|
File size:
449 bytes
|
| Line | |
|---|
| 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 | unsigned long long u; /* system-dependent */
|
|---|
| 11 |
|
|---|
| 12 | x = *ap;
|
|---|
| 13 | n = *bp;
|
|---|
| 14 |
|
|---|
| 15 | if (n <= 0) {
|
|---|
| 16 | if (n == 0 || x == 1)
|
|---|
| 17 | return 1;
|
|---|
| 18 | if (x != -1)
|
|---|
| 19 | return x == 0 ? 1/x : 0;
|
|---|
| 20 | n = -n;
|
|---|
| 21 | }
|
|---|
| 22 | u = n;
|
|---|
| 23 | for(pow = 1; ; )
|
|---|
| 24 | {
|
|---|
| 25 | if(u & 01)
|
|---|
| 26 | pow *= x;
|
|---|
| 27 | if(u >>= 1)
|
|---|
| 28 | x *= x;
|
|---|
| 29 | else
|
|---|
| 30 | break;
|
|---|
| 31 | }
|
|---|
| 32 | return(pow);
|
|---|
| 33 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.