diff options
author | Jakob Kaivo <jkk@ung.org> | 2022-03-28 14:11:39 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2022-03-28 14:11:39 -0400 |
commit | db28fcf89f08307ca5f13cbb9d562ac0e5f9431e (patch) | |
tree | be5ec8a162f685aa01e5dfc5df05b7e2341b9d20 | |
parent | 1b3e4865fcca40e49d02fe2878c3173de92087cc (diff) |
modernize bigsub()
-rw-r--r-- | big.c | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -155,18 +155,20 @@ word big_plus(word x, word y, int signbit) return r; } -word bigsub(x, y) -word x, y; +word bigsub(word x, word y) { - if (big_is_positive(x)) - if (big_is_positive(y)) - return (big_sub(x, y)); - else - return (big_plus(x, y, 0)); /* big_is_positive x, negative y */ - else if (big_is_positive(y)) - return (big_plus(x, y, SIGNBIT)); /* negative x, big_is_positive y */ - else - return (big_sub(y, x)); /* both negative */ + if (big_is_positive(x)) { + if (big_is_positive(y)) { + return (big_sub(x, y)); /* both positive */ + } + return (big_plus(x, y, 0)); /* positive x, negative y */ + } + + if (big_is_positive(y)) { + return (big_plus(x, y, SIGNBIT)); /* negative x, positive y */ + } + + return (big_sub(y, x)); /* both negative */ } word big_sub(x, y) /* ignore input signs, treat x,y as positive */ |