Lua · Variables · Helpers

bit

Bit operations on whole numbers, for scripts written for older Lua.

Lua 5.4 has the operators built in (&, |, ~, <<, >>); these are the same thing as functions.

FunctionWhat it does
bit.band(a, b)a & b.
bit.bor(a, b)a | b.
bit.bxor(a, b)a ~ b.
bit.bnot(a)~a.
bit.lshift(a, n)a << n.
bit.rshift(a, n)a >> n.

#bit.band

bit.band(a, b)

a & b.

#bit.bor

bit.bor(a, b)

a | b.

#bit.bxor

bit.bxor(a, b)

a ~ b.

#bit.bnot

bit.bnot(a)

~a.

#bit.lshift

bit.lshift(a, n)

a << n.

#bit.rshift

bit.rshift(a, n)

a >> n.