Skip to content

Commit

Permalink
Bit-shifting zero should be zero; ref #3620
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Apr 20, 2017
1 parent d2cad9a commit 3567b26
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/numeric.c
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,7 @@ fix_lshift(mrb_state *mrb, mrb_value x)
return x;
}
val = mrb_fixnum(x);
if (val == 0) return x;
if (width < 0) {
return rshift(val, -width);
}
Expand All @@ -1019,6 +1020,7 @@ fix_rshift(mrb_state *mrb, mrb_value x)
return x;
}
val = mrb_fixnum(x);
if (val == 0) return x;
if (width < 0) {
return lshift(mrb, val, -width);
}
Expand Down

0 comments on commit 3567b26

Please sign in to comment.