summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-15 04:43:58 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-15 04:43:58 +0000
commitfc38025c8ea44942db1c242bb39a717b65bf8cf9 (patch)
tree2f5658ef72caec3956f93ec0e3606994e37e9dbc /bignum.c
parentcd237625d4d60dfd0d6e10e04611a69168c83e21 (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.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/bignum.c b/bignum.c
index 2c70b4b8f0..69d69d6f1c 100644
--- a/bignum.c
+++ b/bignum.c
@@ -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);
}