Skip to content
CoolCat467 edited this page Dec 31, 2020 · 1 revision

Backwards compatibility for Lua 5.3; only loaded in 5.3 because package.loaded is prepopulated with the existing global bit32 in 5.2.

Functions:

arshift(x, disp) Return x floor div (//) of two to the power of .

band(...) Return the combined bitwise and of all arguments and 0xffffffff.

bnot(x) Return the bitwise inverse (~) of x.

bor(...) Return the bitwise or of all arguments.

btest(...) Return if bitwise and of all arguments is not equal to zero.

bxor() Return the bitwise xor of all arguments.

extract(n, field, width) Preform n bitwise shifted right by field, bitwise anded with a mask of width.

lrotate(x, disp) Rotate x's bits to the left by disp.

lshift(x, disp) Return x leftshifted by disp trimmed to 32 bits.

replace(n, v, field, width) Preform n bitwise anded with the inverse of mask of width rightsifted by field, bitwise ored with the bitwise and of v and a mask of width rightshifted by field. (n & ~(mask(width) << f)) | ((v & mask(width)) << f)

rrotate(x, disp) Rotate x's bits to the right by disp.

rshift(x, disp) Return x rightshifted by disp trimmed to 32 bits.

Clone this wiki locally