Created
April 23, 2011 09:39
-
-
Save mebens/938502 to your computer and use it in GitHub Desktop.
Functions for quick left and right bitwise shifts in Lua.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function lshift(x, by) | |
return x * 2 ^ by | |
end | |
function rshift(x, by) | |
return math.floor(x / 2 ^ by) | |
end |
Thanks. Not sure what I was thinking here.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@blackknight36
0x03 is hexadecimal 3 = binary 11
shifting binary 11 to right twice results 0
floor is correct