summaryrefslogtreecommitdiff
path: root/big.c
diff options
context:
space:
mode:
Diffstat (limited to 'big.c')
-rw-r--r--big.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/big.c b/big.c
index 02753f6..8fba599 100644
--- a/big.c
+++ b/big.c
@@ -585,30 +585,39 @@ word ms2d(word x)
return (digit(x) * IBASE + d);
}
-word bigpow(x, y) /* assumes y big_is_positive */
-word x, y;
+/* assumes y big_is_positive */
+word bigpow(word x, word y)
{
- word d, r = make(INT, 1, 0);
- while (rest(y)) { /* this loop has been unwrapped once, see below */
+ word d;
+ word r = make(INT, 1, 0);
+
+ /* this loop has been unwrapped once, see below */
+ while (rest(y)) {
word i = DIGITWIDTH;
d = digit(y);
while (i--) {
- if (d & 1)
+ if (d & 1) {
r = bigtimes(r, x);
+ }
x = bigtimes(x, x);
d >>= 1;
}
y = rest(y);
}
+
d = digit(y);
- if (d & 1)
+ if (d & 1) {
r = bigtimes(r, x);
+ }
+
while (d >>= 1) {
x = bigtimes(x, x);
- if (d & 1)
+ if (d & 1) {
r = bigtimes(r, x);
+ }
}
- return (r);
+
+ return r;
}
double bigtodbl(x)