diff options
-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 */ |