From 6831094e2b4d9918b32741c7509416495142ae61 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Mon, 28 Mar 2022 14:02:54 -0400 Subject: modernize bigplus() --- big.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/big.c b/big.c index d1cff5f..919390d 100644 --- a/big.c +++ b/big.c @@ -100,21 +100,24 @@ word bignegate(word x) return make(INT, SIGNBIT | hd[x], tl[x]); } -word bigplus(x, y) -word x, y; +word bigplus(word x, word y) { - if (big_is_positive(x)) - if (big_is_positive(y)) + if (big_is_positive(x)) { + if (big_is_positive(y)) { return (big_plus(x, y, 0)); - else - return (big_sub(x, y)); - else if (big_is_positive(y)) + } + return (big_sub(x, y)); + } + + if (big_is_positive(y)) { return (big_sub(y, x)); - else - return (big_plus(x, y, SIGNBIT)); /* both negative */ + } + + return (big_plus(x, y, SIGNBIT)); /* both negative */ } -word big_plus(x, y, signbit) /* ignore input signs, treat x,y as positive */ +/* ignore input signs, treat x,y as positive */ +word big_plus(x, y, signbit) word x, y; int signbit; { -- cgit v1.2.1