BitOperations.jl

BitOperations is a Julia package for bit and register operations. It is mainly intended for Julia code that needs to communicate with hardware (e.g. with a register-based memory model) or work with intricate binary data formats.

While bit-manipulation operations are typically easy to implement on-the-fly, using a set of library functions (as provided by this package) improves code readability and reduces the potential for errors.

BitOperations.jl conventions:

  • Bit indices start at zero: bmask(Int, 0) == 0x01, bmask(Int, 1) == 0x02.

Provided functions

Basic bit operations:

bsizeof, bmask, lsbmask, msbmask, bget, bset, bclear, bflip, lsbget, msbget

Zigzag encoding/decoding (Google Protocol Buffers compatible):

zigzagenc, zigzagdec