diff options
Diffstat (limited to 'big.c')
-rw-r--r-- | big.c | 32 |
1 files changed, 20 insertions, 12 deletions
@@ -265,26 +265,34 @@ word big_sub(word x, word y) return r; } -int bigcmp(x, y) /* returns +ve,0,-ve as x greater than, equal, less than y */ -word x, y; +/* returns +ve,0,-ve as x greater than, equal, less than y */ +int bigcmp(word x, word y) { - word d, r, s = big_is_negative(x); - if (big_is_negative(y) != s) + word s = big_is_negative(x); + if (big_is_negative(y) != s) { return (s ? -1 : 1); - r = digit0(x) - digit0(y); + } + + word r = digit0(x) - digit0(y); for (;;) { x = rest(x); y = rest(y); - if (!x) - if (y) + + if (!x) { + if (y) { return (s ? 1 : -1); - else - return (s ? -r : r); - if (!y) + } + return (s ? -r : r); + } + + if (!y) { return (s ? -1 : 1); - d = digit(x) - digit(y); - if (d) + } + + word d = digit(x) - digit(y); + if (d) { r = d; + } } } |