diff options
| author | Yuichiro MASUI <[email protected]> | 2012-11-17 15:57:01 +0900 |
|---|---|---|
| committer | Yuichiro MASUI <[email protected]> | 2012-11-17 15:57:01 +0900 |
| commit | 93751385736ff8552d51b010415f7eed2341bc6f (patch) | |
| tree | 2eac57dcdb7de016f33cb6998d73274592bff157 | |
| parent | 7cea9d7b945a4b00cef699f47c07654f8b7bd579 (diff) | |
| download | mruby-93751385736ff8552d51b010415f7eed2341bc6f.tar.gz mruby-93751385736ff8552d51b010415f7eed2341bc6f.zip | |
l/rshift width as int. It was unsigned long
| -rw-r--r-- | src/numeric.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/numeric.c b/src/numeric.c index 98a60ed30..8bf2b3382 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -948,7 +948,7 @@ fix_xor(mrb_state *mrb, mrb_value x) } static mrb_value -lshift(mrb_state *mrb, mrb_int val, unsigned long width) +lshift(mrb_state *mrb, mrb_int val, int width) { if (width > (sizeof(mrb_int)*CHAR_BIT-1)) { mrb_raisef(mrb, E_RANGE_ERROR, "width(%d) > (%d:sizeof(mrb_int)*CHAR_BIT-1)", width, @@ -959,7 +959,7 @@ lshift(mrb_state *mrb, mrb_int val, unsigned long width) } static mrb_value -rshift(mrb_int val, unsigned long i) +rshift(mrb_int val, int i) { if (i >= sizeof(mrb_int)*CHAR_BIT-1) { if (val < 0) return mrb_fixnum_value(-1); @@ -988,7 +988,7 @@ fix_lshift(mrb_state *mrb, mrb_value x) y = bit_coerce(mrb, y); width = mrb_fixnum(y); if (width < 0) - return rshift(val, (unsigned long)-width); + return rshift(val, -width); return lshift(mrb, val, width); } @@ -1012,7 +1012,7 @@ fix_rshift(mrb_state *mrb, mrb_value x) i = mrb_fixnum(y); if (i == 0) return x; if (i < 0) - return lshift(mrb, val, (unsigned long)-i); + return lshift(mrb, val, -i); return rshift(val, i); } |
