Skip to content
This repository has been archived by the owner on Jul 1, 2018. It is now read-only.

bitop library

SquidDev edited this page Sep 22, 2016 · 2 revisions

The bitop library provides an extended set of functions to operator on the bits of integers. It is also twice as fast as vanilla's library as it does not have to go through CC's conversion mechanism.

Examples

local value = tonumber(read())
local masked = bitop.band(0xff, value)

print(bitop.tohex(masked, 2))

Configuration

The bitop library can be enabled or disabled using the APIs.bitop config option.

Documentation

The API is modelled off of LuaJIT's bit library and so there are differences to the vanilla bit library.

  • More than two values can be passed for band, bor, and bxor.
  • lshift, rshift and arshift instead of blshift, blogic_rshift and brshift (like the bit32 API).
  • Added tobit, tohex, rol, ror and bswap
Clone this wiki locally