Brutile Posted October 29, 2014 Share Posted October 29, 2014 Is there a way to use bit shifting in lua? i.e. 1<<8 to get 256 Quote Link to comment Share on other sites More sharing options...
Guppy Posted October 29, 2014 Share Posted October 29, 2014 not as easily but it can be done; http://lua-users.org/wiki/BitwiseOperators I think LE uses lua 5.2? 1 Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
macklebee Posted October 29, 2014 Share Posted October 29, 2014 Looks easy to me... its already inherent to LE's current lua implementation as long as sandboxing is disabled. 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) Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.