diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-02-15 04:43:58 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-02-15 04:43:58 +0000 |
commit | fc38025c8ea44942db1c242bb39a717b65bf8cf9 (patch) | |
tree | 2f5658ef72caec3956f93ec0e3606994e37e9dbc /bignum.c | |
parent | cd237625d4d60dfd0d6e10e04611a69168c83e21 (diff) |
* bignum.c (rb_big_rshift): should properly convert the nagative
value to 2's compliment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@2072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -1293,6 +1293,10 @@ rb_big_rshift(x, y) else return INT2FIX(-1); } + if (!RBIGNUM(x)->sign) { + x = rb_big_clone(x); + rb_big_2comp(x); + } xds = BDIGITS(x); i = RBIGNUM(x)->len; j = i - s1; z = bignew(j, RBIGNUM(x)->sign); @@ -1302,6 +1306,9 @@ rb_big_rshift(x, y) zds[j] = BIGLO(num); num = BIGUP(xds[i]); } + if (!RBIGNUM(x)->sign) { + rb_big_2comp(z); + } return bignorm(z); } |