Bit operations
32-bit integer arithmetic and bitwise helpers.
Arithmetic on 32-bit unsigned values.
print(bit.badd(7, 3), bit.bsub(7, 3), bit.bmul(7, 3), bit.bdiv(9, 3))
Bitwise operations.
print(bit.band(12, 10), bit.bor(12, 10), bit.bxor(12, 10), bit.bnot(5))
Left, logical right and arithmetic right shifts.
print(bit.lshift(1, 4), bit.rshift(16, 2), bit.arshift(0xFFFFFFF0, 4))
Rotates a value left or right.
print(bit.rol(0x12345678, 8), bit.ror(0x12345678, 8))
Converts to an integer or hexadecimal string.
print(bit.tobit(0xFFFFFFFF), bit.tohex(255))