diff options
-rw-r--r-- | lbitlib.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbitlib.c,v 1.9 2010/10/27 16:50:32 roberto Exp roberto $ | 2 | ** $Id: lbitlib.c,v 1.10 2010/10/28 15:17:29 roberto Exp roberto $ |
3 | ** Standard library for bitwise operations | 3 | ** Standard library for bitwise operations |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -108,7 +108,7 @@ static int b_rshift (lua_State *L) { | |||
108 | static int b_arshift (lua_State *L) { | 108 | static int b_arshift (lua_State *L) { |
109 | b_uint r = getuintarg(L, 1); | 109 | b_uint r = getuintarg(L, 1); |
110 | int i = luaL_checkint(L, 2); | 110 | int i = luaL_checkint(L, 2); |
111 | if (i < 0 || !(r & (1 << (NBITS - 1)))) | 111 | if (i < 0 || !(r & ((b_uint)1 << (NBITS - 1)))) |
112 | return b_shift(L, r, -i); | 112 | return b_shift(L, r, -i); |
113 | else { /* arithmetic shift for 'negative' number */ | 113 | else { /* arithmetic shift for 'negative' number */ |
114 | if (i >= NBITS) r = ALLONES; | 114 | if (i >= NBITS) r = ALLONES; |