summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2022-03-28 14:00:26 -0400
committerJakob Kaivo <jkk@ung.org>2022-03-28 14:00:26 -0400
commitc8a72f0312e7260154627183efdede99aa8da25f (patch)
tree36a46052454d97d04e5097adcdea23f8f71a90de
parent8a13fcc5633a4c0acbf04662bfdcc61fdb6f756c (diff)
modernize bignegate()
-rw-r--r--big.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/big.c b/big.c
index 022b49d..d1cff5f 100644
--- a/big.c
+++ b/big.c
@@ -88,13 +88,16 @@ long long get_int(word x)
return (sign ? -n : n);
}
-word bignegate(x)
-word x;
+word bignegate(word x)
{
- if (bigzero(x))
- return (x);
- return (make
- (INT, hd[x] & SIGNBIT ? hd[x] & MAXDIGIT : SIGNBIT | hd[x], tl[x]));
+ if (bigzero(x)) {
+ return x;
+ }
+
+ if (hd[x] & SIGNBIT) {
+ return make(INT, hd[x] & MAXDIGIT, tl[x]);
+ }
+ return make(INT, SIGNBIT | hd[x], tl[x]);
}
word bigplus(x, y)