Tag: maths


Simulate Bitwise Shift Operators in Lua

EDIT: Here's a couple functions which will do the shift operations that I've put in gist #938502.

The fact that Lua doesn't have bitwise operators is a pain. There are pure Lua implementations out there, such as LuaBit, but I find these to be a little slow (I think LuaBit using tables or something like that). I've found a way to simulate both the left-shift and right-shift operator by using some simple mathematics.

Read more