Bit operations in Lua

I am using a GX400W to interface with some other equipment, and as part of the communication protocol I need to perform a CRC. This uses lots of bit-shifting and masking, which I don’t believe is natively supported in Lua. There are a number of extensions (BitOps - for adding bit operations. Are any of these integrated, or are there plans to be?

I can write equivalent functions using divide-by-2 and multiply-by-2 and similar to achieve rotations and masking, but it would be better if there was a proper library to do it.

Hi Alan,
My apologies for the delay in response. You’re right we don’t currently have a bitwise operation library included in our current release and it is definitely needed. We do plan to include a bitwise library (likely bit32 found in Lua 5.2) in the next official ALEOS AF targeted for end of September.

Thanks again for the message, your feedback and feature requests are really appreciated.


For what it 's worth: the upcoming ALEOS version 4.3.4 will bring a new version of AAF that natively support bitwise operation.
We backported the Lua5.2 bitlib into the framework, so the API is strictly the same:
ALEOS 4.3.4 should be released in less than a month from now.

I don’t see a bitlib in ALEOS 4.3.4. Am I missing something? Did this lib get pushed back?


The documentation has not been updated but the library is actually integrated since ALEOS 4.3.4.
You can use it doing:

local bit32 =  require 'bit32'
local function main()
    local var = bit32.lshift(2, 10)

As previouly stated, the AAF bit32 library API is the same as