band( first, second )
Calculates the bitwise and of two numbers.
first
The first number.

second
The second number.

Superseded by & operator

The & operator added in 0.2.0 performs the same function as band() and is now the recommended way to do bitwise and, as it uses fewer tokens, costs fewer cycles at runtime, and runs on the real host CPU much more efficiently. Simply replace band(a,b) with a&b.

Examples

--     0x7 = 0111 binary
-- and 0xd = 1101 binary
-- -------
--     0x5 = 0101 binary
print(band(0x7, 0xd))  -- 5

print(0x7 & 0xd)       -- preferred method

See also

Community content is available under CC-BY-SA unless otherwise noted.