diff options
| -rw-r--r-- | lvm.c | 2 | ||||
| -rw-r--r-- | testes/bitwise.lua | 5 |
2 files changed, 6 insertions, 1 deletions
| @@ -766,7 +766,7 @@ lua_Number luaV_modf (lua_State *L, lua_Number m, lua_Number n) { | |||
| 766 | /* | 766 | /* |
| 767 | ** Shift left operation. (Shift right just negates 'y'.) | 767 | ** Shift left operation. (Shift right just negates 'y'.) |
| 768 | */ | 768 | */ |
| 769 | #define luaV_shiftr(x,y) luaV_shiftl(x,-(y)) | 769 | #define luaV_shiftr(x,y) luaV_shiftl(x,intop(-, 0, y)) |
| 770 | 770 | ||
| 771 | lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y) { | 771 | lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y) { |
| 772 | if (y < 0) { /* shift right? */ | 772 | if (y < 0) { /* shift right? */ |
diff --git a/testes/bitwise.lua b/testes/bitwise.lua index 59781f5d..9509f7f0 100644 --- a/testes/bitwise.lua +++ b/testes/bitwise.lua | |||
| @@ -45,6 +45,11 @@ assert(-1 >> numbits == 0 and | |||
| 45 | -1 << numbits == 0 and | 45 | -1 << numbits == 0 and |
| 46 | -1 << -numbits == 0) | 46 | -1 << -numbits == 0) |
| 47 | 47 | ||
| 48 | assert(1 >> math.mininteger == 0) | ||
| 49 | assert(1 >> math.maxinteger == 0) | ||
| 50 | assert(1 << math.mininteger == 0) | ||
| 51 | assert(1 << math.maxinteger == 0) | ||
| 52 | |||
| 48 | assert((2^30 - 1) << 2^30 == 0) | 53 | assert((2^30 - 1) << 2^30 == 0) |
| 49 | assert((2^30 - 1) >> 2^30 == 0) | 54 | assert((2^30 - 1) >> 2^30 == 0) |
| 50 | 55 | ||
