diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-09-08 09:17:55 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-09-08 09:17:55 +0000 |
commit | b0e1436164e4004f048bac4babc220e0deccb4f9 (patch) | |
tree | 1e46ec5aa4b12c076ba9c535ff889a49b9a7b3c1 /bignum.c | |
parent | 48acbc5e03622f1eb0423a6c2a3a603f61acfac6 (diff) |
1.1c5
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 19 |
1 files changed, 4 insertions, 15 deletions
@@ -557,22 +557,11 @@ bigadd(x, y, sign) long num; unsigned int i, len; - if (RBIGNUM(x)->sign == (RBIGNUM(y)->sign ^ sign)) { - if (RBIGNUM(y)->sign == sign) return bigsub(y, x); + sign = (sign == RBIGNUM(y)->sign); + if (RBIGNUM(x)->sign != sign) { + if (sign) return bigsub(y, x); return bigsub(x, y); } - else if (sign == 0) { - /* x - y */ - if ((RBIGNUM(x)->sign == 0) && (RBIGNUM(y)->sign == 1)) { - /* x is negative and y is positive. */ - /* return -(abs(x) + y) */ - VALUE ret; - RBIGNUM(x)->sign = 1; /* x = abs(x) */ - ret = bigadd(x, y, 1); /* ret = x + y (recursive call) */ - RBIGNUM(ret)->sign = 0; /* ret = -ret */ - return ret; - } - } if (RBIGNUM(x)->len > RBIGNUM(y)->len) { len = RBIGNUM(x)->len + 1; @@ -581,7 +570,7 @@ bigadd(x, y, sign) else { len = RBIGNUM(y)->len + 1; } - z = bignew(len, sign==RBIGNUM(y)->sign); + z = bignew(len, sign); len = RBIGNUM(x)->len; for (i = 0, num = 0; i < len; i++) { |