Bitwise library

As a Roblox developer, it is currently too hard to implement things that require bitwise manipulation.
The addition of a built-in bitwise library would make concepts such as bit fields, bit packing, compression, hashing, and encryption much more feasible for developers to implement.

Lua BitOp is an example of a pre-existing Lua binding that does what I’m looking for.

24 Likes

I can support this; it’s currently a right pain to implement this manually, and it’s useful for so many things, such as (as listed by Fractality) hashing, encryption, and compression.

2 Likes

I think it would be awesome if we could have the bitwise operators from lua 5.3.

4 Likes

Has anyone tried using bitwise libraries in Roblox? How did that go?
@Maelstronomer, did you do this for your accelerator project?

1 Like

I used a bitwise library I found on the internet to do some simplex noise a while back. This was before the built-in noise function was a thing. It would have been faster and more memory efficient had there been built in operators.

1 Like

The catch of 5.3’s bitwise ops is that they depend on the abomination that is the integer subtype.

Built-in operators with BitOp’s elegant semantics would be convenient, albeit overkill. For all intents and purposes, a library is fine.

There’s no built-in simplex noise generator, so this remains a good use case.

2 Likes

Bits can be represented as tables (e.g. {0,0,1,1,0,1,0,1} or {true,false,false,true,false}) which makes working with it quite easy. But like Nimblz mentioned, it’s not very (memory/time) efficient.

2 Likes

O(n) shifts? oh god

2 Likes

I agree with this. I have a simplex based terrain generator that would greatly benefit from native bitwise operators.

1 Like

I also ported Luaforge user hanzhao’s bitwise operators into a ModuleScript a couple of years ago. I have no idea how good it is, but it works (if anyone is in desperate need of them now).

Still would be waaaay better to have native support.

2 Likes

I think the addition of the already included-into lua bit32 sub-section would be a useful addition to the Roblox developer community.

1 Like