Give us a native BigInteger class

As a dev I often myself in situations where I need to perform calculations between very large precise integers that can’t be directly represented inside the Roblox engine due to precision issues. Such numbers are often used for complex math for tasks such as encryption and server-side security. Another use case this would be useful for is rendering mathematical fractals, such as the mandelbrot set, that in Roblox loses precision after a certain point of zooming in(due to floating point errors). Many devs have tried to create BigInteger modules, that often work by internally representing very large numbers as an array of smaller ones, but those modules are often slow, especially when the numbers get large(for example over 1024 bits) or multiple calculations need to be done to derive a result. Also those modules create unnecessary lag due to the nature of handling operation like that using lists of smaller numbers.

What I’m asking for:

I’m asking for a native BigInteger Roblox class, that copies the format of value classes. Basically it only has one property named Value and that value is represented internally as a big integer(instead of a common Roblox number). The class will support a list of operations, including addition, subtraction, multiplication, division, mod, and comparisons(for example equal, smaller than, bigger than). Also it will have a single method for fetching the current value of the class as a byte string(or a hex string, or both) so we can work with the outputs of the class after performing operations. It will also support the tostring operation for debugging reasons, that converts the internally stored number to a decimal string. Lastly the class will also be able to work without being parented to the game itself, so we can use it inside scripts(as an instance of the class).

The entire purpose of the class is to perform the operations internally and optimally to minimize time and any possible lag.

The class will be used for situations where information matters, not for things like big numbers in simulators or physics, where scientific notation is enough.

11 Likes

We do not currently plan to add built-in support for such a class.

You should continue using the libraries people make and we are looking into ways of making sharing and collaborating on Luau libraries easier in the Roblox Studio. (people today often re-implement stuff instead of re-using the same modules)

1 Like

We are looking into providing common encryption/hashing algorithms in the engine API as those will be more efficient than doing it manually even if there was a bignum.
Additionally, we are looking on providing more building blocks to make custom bignum modules more efficient, like 32*32 bit multiplication giving low/high 32 bit results etc.
But no timeline at this point.

4 Likes