Skip to content

Instantly share code, notes, and snippets.

@Python1320
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Python1320/e6b98867fc81735e96ba to your computer and use it in GitHub Desktop.
Save Python1320/e6b98867fc81735e96ba to your computer and use it in GitHub Desktop.
Hacky unsigned bitlib
ubit=ubit or {}
local bit=bit
local ubit=ubit
function gen(name)
local f=bit[name]
if not f then error"?!?" end
local function func(...)
local ret = f(...)
return ret>=0 and ret or 0x100000000+ret
end
ubit[name] = func
bit['u'..name] = func
end
gen'rol'
gen'rshift'
gen'ror'
gen'bswap'
gen'bxor'
gen'bor'
gen'arshift'
gen'bnot'
gen'tobit'
gen'lshift'
gen'band'
ubit.tohex=bit.tohex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment