Number compression, can I specify unsigned/numbersize?

I’m working with something that needs to store many numbers. And after some research it seems roblox’s numbers stores 64 bits in memory. When none of my numbers will be decimals, negative, or need to be above 8bits total. If I can somehow specify this I can save ~80% of memory, allowing for much higher limits.

It appears vector2 and vector3 have 16bit counterparts, but I can’t seem to find a way to specify any sort of compression for a single number.

Is there anyway I can do this?

Have to tried storing the information in a byte?
I am asking as that is 8 bits so meets your needs.

1 Like

If your trying to save data into the datastore then this video will help

But if your trying to reduce ram usage

Then you can use bitwise operations to save multiple values into 1 variable

-- the 2 numbers we want to save
local value1 = 123
local value2 = 46346

-- save both numbers into a single variable (double)
local save = bit32.replace(value1, value2, 16, 16)

-- extract the 2 values back from the single variable (double)
local loadedValue1 = bit32.extract(save, 0, 16)
local loadedValue2 = bit32.extract(save, 16, 16)

-- print the 2 values