Created
November 27, 2010 15:39
-
-
Save kronos/717987 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 0e39144fcc6c3bf400ad6ddede9effb6e5c4db0e Mon Sep 17 00:00:00 2001 | |
| From: Ivan Samsonov <hronya@gmail.com> | |
| Date: Sat, 27 Nov 2010 18:32:24 +0300 | |
| Subject: [PATCH 1/2] Spec for edge case in Bignum#>> | |
| --- | |
| spec/ruby/core/bignum/right_shift_spec.rb | 2 ++ | |
| 1 files changed, 2 insertions(+), 0 deletions(-) | |
| diff --git a/spec/ruby/core/bignum/right_shift_spec.rb b/spec/ruby/core/bignum/right_shift_spec.rb | |
| index da367d1..4f564df 100644 | |
| --- a/spec/ruby/core/bignum/right_shift_spec.rb | |
| +++ b/spec/ruby/core/bignum/right_shift_spec.rb | |
| @@ -27,6 +27,8 @@ describe "Bignum#>> with n >> m" do | |
| (-42949672980000000000000 >> 15).should == -1310720000610351563 | |
| (-42949672980000000000001 >> 15).should == -1310720000610351563 | |
| + | |
| + (-0xfffffffffffffffff >> 32).should == -68719476736 | |
| end | |
| it "respects twos complement signed shifting for very large values" do | |
| -- | |
| 1.6.6.1 | |
| From 19f37dc582dd007226f2b9534ab275334a762c9a Mon Sep 17 00:00:00 2001 | |
| From: Ivan Samsonov <hronya@gmail.com> | |
| Date: Sat, 27 Nov 2010 18:35:12 +0300 | |
| Subject: [PATCH 2/2] Use native_int and explicit conversion to native_int in Bignum#>> | |
| --- | |
| vm/builtin/bignum.cpp | 2 +- | |
| 1 files changed, 1 insertions(+), 1 deletions(-) | |
| diff --git a/vm/builtin/bignum.cpp b/vm/builtin/bignum.cpp | |
| index d0e09af..096ebb4 100644 | |
| --- a/vm/builtin/bignum.cpp | |
| +++ b/vm/builtin/bignum.cpp | |
| @@ -701,7 +701,7 @@ namespace rubinius { | |
| } | |
| if(!bit_inside_shift) { | |
| - int shift_mask = (1 << (shift % DIGIT_BIT)) - 1; | |
| + native_int shift_mask = ((native_int)1 << (shift % DIGIT_BIT)) - 1; | |
| bit_inside_shift = (DIGIT(a, full_digits) & shift_mask); | |
| } | |
| -- | |
| 1.6.6.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment