bitslop bitslop bitslop bitslop
if your working with binary in lua you can use the prefix 0b to denote a binary number like so
local mybinary = 0b00010100
print(mybinary) -- prints 20
This is literally amazing
… nice job!
It’s not possible to represent all 64-bit integers in Luau regardless. Luau numbers can only represent all 32-bit integers. That’s because Luau uses float64 (otherwise known as binary64, or double) for numbers, and since floats have to fit in non-integer values as well, they sacrifice some of their ability to store integers.
I just wanna say, im reading on the studio now and im seeing all these numbers BROOOO Im so so so confused rn
Not sure if this will ever get used in Roblox. Great concept and explanation! Effort post :DD
So how does everything come together when u are working with negative numbers?
Im trying to convert a vector3int16 into bit32 and as a test the positions are completely random, that also means that in some cases it can be negative and that causes the script to misinterpret the number when it decodes it. For example -5 turns into 16379
Bit32 libary does not, and as I’m aware, is not planning to add negative number support.
A way to simulate negative numbers is to shift each bit’s value so that bit 1’s value is 1 and bit 0’s value is 1/2, and so on making bit 0’s value 1/4, bit 1’s value 1/2 and vit 2’s value of 1.
Instead of the calculation 2^bitindex*value (value being either 1 or 0), an offset would need to be added.
Example:
2^(bitindex-offset)*value
Arithmetic with bit32 will not be impacted if both bits have same offset values.
With the original thread soon being 2 years old, I’ll make a more in-depth tutorial on the Bit32 library and on Binary Multiplication, Division and other calculations. I’ll try release the updated tutorial right on the 2 year anniversary of this post.
New, updated tutorial comming soon as it’s the two-year anniversary of the original post!
Hey did you make it? I would like to learn more on the reasons why it would be used over regular numbers and such? easier on memory? computation? Can it be shared across scripts, modules, frameworks?
It’s been 1 year bro where’s the new tutorial
Bit32 products are numbers so yes, they can be used over scripts. But if you are at the point of using Bit32, you may aswell store them in buffers, which I’d mention in the next tutorial if I don’t forget.
Blud it’s been 5 months
looks useful ima boomark this

what happened to the post?
i got a notification and i find the post deleted?