|
|
@ -38,6 +38,18 @@ d = d << 32 |
|
|
|
assert(a | b ~ c & d == 0xF4000000 << 32) |
|
|
|
assert(~~a == a and ~a == -1 ~ a and -d == ~d + 1) |
|
|
|
|
|
|
|
|
|
|
|
do -- constant folding |
|
|
|
local code = string.format("return -1 >> %d", math.maxinteger) |
|
|
|
assert(load(code)() == 0) |
|
|
|
local code = string.format("return -1 >> %d", math.mininteger) |
|
|
|
assert(load(code)() == 0) |
|
|
|
local code = string.format("return -1 << %d", math.maxinteger) |
|
|
|
assert(load(code)() == 0) |
|
|
|
local code = string.format("return -1 << %d", math.mininteger) |
|
|
|
assert(load(code)() == 0) |
|
|
|
end |
|
|
|
|
|
|
|
assert(-1 >> 1 == (1 << (numbits - 1)) - 1 and 1 << 31 == 0x80000000) |
|
|
|
assert(-1 >> (numbits - 1) == 1) |
|
|
|
assert(-1 >> numbits == 0 and |
|
|
|