I’ve developing my game for around a week now and came across a roadblock that I can’t seem to cross unlike the others. I have an incremental simulator game where number reach past the maximum integer value of 9,223,372,036,854,775,807. I’ve been messing around all day trying to get past this limit and trying to learn how to use these modules that can help exceed the maximum value but just can’t figure them out. If anyone is experienced or would like to help out, feel free to reach out. All help is appreciated.
You’re using the wrong data type. Your game is a scaling game not an information game, this means that when it comes to a number, you only care about the digits at the front of it when doing any meaningful operations. Basically you can assume that 9Qn + 1 is 9Qn, since in order to change 9Qn in any meaningful way by only adding 1 to it would take years.
For situations like this you need Floating-point arithmetic, basically numbers that lose precision after a certain digit point that is insignificant to even consider in your calculations. In Roblox, this type of numbers can be stored in NumberValue instances (instead of IntValues that you use for integers). Also luau will figure it out automatically for number variables in scripts(so that should not be an issue there).
Using built-in float numbers should be able to give you numbers up to 308 digits long before turning them to inf (infinity). For reference the number you provided only has 19 digits, much lower than what you can achieve natively. Now if you want to go above 308 digits, you will have to make a module for handling numbers in a custom way, or find one online (there’re plenty). Basically your module will have to store the mantissa and exponent independently and do math operations in a more creative way rather than combining them and doing the operations with the combined numbers.