Browse Source

correction to allow lua_Unsigned larger than usigned int

Roberto Ierusalimschy 14 years ago
parent
commit
c7d4da8746
1 changed files with 2 additions and 2 deletions
  1. 2 2
      lbitlib.c

+ 2 - 2
lbitlib.c

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