Created
April 6, 2010 23:50
-
-
Save kronos/358283 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
| diff --git a/vm/builtin/fixnum.cpp b/vm/builtin/fixnum.cpp | |
| index 679c5f1..5d51798 100644 | |
| --- a/vm/builtin/fixnum.cpp | |
| +++ b/vm/builtin/fixnum.cpp | |
| @@ -126,7 +126,7 @@ namespace rubinius { | |
| native_int denominator = other->to_native(); | |
| native_int quotient = div(state, other)->to_native(); | |
| native_int modulo = numerator - denominator * quotient; | |
| - | |
| + | |
| if((modulo < 0 && denominator > 0) || (modulo > 0 && denominator < 0)) { | |
| return Fixnum::from(modulo + denominator); | |
| } else { | |
| @@ -283,14 +283,20 @@ namespace rubinius { | |
| Integer* Fixnum::left_shift(STATE, Fixnum* bits) { | |
| native_int shift = bits->to_native(); | |
| + native_int self = to_native(); | |
| + | |
| + if (self == 0) { | |
| + return Fixnum::from(0); | |
| + } | |
| + | |
| if(shift < 0) { | |
| return right_shift(state, Fixnum::from(-shift)); | |
| } | |
| - native_int self = to_native(); | |
| + native_int check = self > 0 ? self : -self; | |
| if(shift >= (native_int)FIXNUM_WIDTH | |
| - || self >> ((native_int)FIXNUM_WIDTH - shift) > 0) { | |
| + || check >> ((native_int)FIXNUM_WIDTH - shift) > 0) { | |
| return Bignum::from(state, self)->left_shift(state, bits); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment