When using numbers on Roblox, there is a max number, which I believe is 2,147,483,647 (corrected by CloneTrooper1019). However, some people get around this, such as Mining Simulator:
What methods can you use to do this?
When using numbers on Roblox, there is a max number, which I believe is 2,147,483,647 (corrected by CloneTrooper1019). However, some people get around this, such as Mining Simulator:
What methods can you use to do this?
You’ll need some implementation of BigNum.
I haven’t tried this module, but it’s in pure Lua 5.1 so it should port over to Roblox nicely with relative ease: euler/BigNum.lua at master · ennorehling/euler · GitHub
Not exactly sure how you’d serialize it to data storage with this module, but that’s something you should be able to look into.
Can confirm this is working.
Haven’t taken too much of a look at it so I don’t know how i would save the BigNums to a data store yet. Will try figuring that out soon.
You could also just use number values instead of intvalues
Number values go upto 10^300 and lua can handle them without any outside library
As far as I know, this isn’t true and I just tested it.
In fact, it doesn’t seem to work at around 10^23.
those are called floating point precision errors and occurr because they dont store the full number (kinda)
I know, thus it’s not useful for the OP’s use cases.
didn’t they increase int values to 64-bit?
For reference the largest value you can have now is 9,223,372,036,854,775,807 when using an IntValue.
Also, the maximum integer value that can be stored with precision in a Lua number (or more generally in a double-precision number) is 2^53 or around 15 quadrillion. Depending on your purposes this might not be enough, but it’s good to know.
And if datastore of the number is an issue, you could potentially save the number as a string and convert it back to a number on loading if it were to be that big of a problem.
Can you upload the file for the roblox version of BigNum? My ported version is having an error while loading :\
Edit*: Nvm I found this: https://raw.githubusercontent.com/RoStrap/Math/master/BigNum.lua HOWEVER for some reason having a large number powered by itself makes a negative large number rather than a positive cus their both positive.
I would imagine you could create a separate value for each next big number, for example Value: 10 (Billion), Value: 500 (Million), Value: 875,000
So basically just breaking it up. When it comes to the math, just account for this and add/subtract based on all these values.