Hi guys,
I’m just in the process of doing bit packing and unpacking functions for the Kurzweil PC3 (unfortunately it’s different to the Morpo method that’s already build into Ctrlr).
Just putting a list of bitwise functions for LUA that I found to remind myself, and also in case anyone else is looking for them in the future.
This appears to be the list of available bitwise operations:
bit.tobit(x) — normalize number to the numeric range of
bit.tohex(x[,n]) — convert x to hex with n digits (default 8)
bit.bnot(x) — bitwise not of x
bit.band(x1[,x2…]) — bitwise and of x1, x2, …
bit.bor(x1[,x2…]) — bitwise or of x1, x2, …
bit.bxor(x1[,x2…]) — bitwise xor of x1, x2, …
bit.lshift(x, n) — left-shift of x by n bits
bit.rshift(x, n) — logical right-shift of x by n bits
bit.arshift(x, n) — arithmetic right-shift of x by n bits
bit.rol(x, n) — left-rotate of x by n bits
bit.ror(x, n) — right-rotate of x by n bits
bit.bswap(x) — byte-swap of x (little-endian <-> big-endian)
From http://www.leadwerks.com/werkspace/topic/11020-bit-shifting-in-lua/
Also, these pages may be helpful – http://www.lua.org/manual/5.3/manual.html
Section 6.7 of http://www.lua.org/manual/5.2/manual.html#6.7
Still testing but I think both bit.band and bit32.band will work equally. Happy to be corrected if that’s incorrect.
The Puppeteer
http://godlike.com.au