diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-05-13 07:26:47 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-05-13 07:26:47 +0000 |
commit | ae2fe781dd4aae16a2f03a4b9fb93514eb9886d4 (patch) | |
tree | bc7b2f6399af854b2b7e3515916c5f51d970bf57 /bignum.c | |
parent | ad592443af373c3bbe61b41df106734856ad3072 (diff) |
1.1b9_19
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -558,6 +558,18 @@ bigadd(x, y, sign) if (RBIGNUM(y)->sign == 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; |