Attempting to perform arithmetic on extremely large numbers?

Hi! So I have a simulator with extremely large numbers and when it gets to a certain number, it just won’t increase it any more. How can I handle this?

increaseClickRE.OnServerEvent:Connect(function(plr, baseAmount)
	if plr:IsInGroup(9487345) then
		print(1 * math.round(((((baseAmount * plr.ClickMultiplier.Value) * plr.PetMultiplier.Value) * plr:FindFirstChild("Multiplier").Value)) * 2) * plr:WaitForChild("RankMultiplier").Value)
		plr:WaitForChild("leaderstats"):WaitForChild("Total Crowns").Value += 1 * math.round(((((baseAmount * plr.ClickMultiplier.Value) * plr.PetMultiplier.Value) * plr:FindFirstChild("Multiplier").Value)) * 2) * plr:WaitForChild("RankMultiplier").Value
		
		plr:WaitForChild("leaderstats"):WaitForChild("Crowns").Value +=  1 * math.round(((((baseAmount * plr.ClickMultiplier.Value) * plr.PetMultiplier.Value) * plr:FindFirstChild("Multiplier").Value)) * 2) * plr:WaitForChild("RankMultiplier").Value
	else
		plr:WaitForChild("leaderstats"):WaitForChild("Total Crowns").Value += 1 * math.round(((baseAmount * plr.ClickMultiplier.Value) * plr.PetMultiplier.Value) * plr:FindFirstChild("Multiplier").Value) * plr:WaitForChild("RankMultiplier").Value
		plr:WaitForChild("leaderstats"):WaitForChild("Crowns").Value += 1 * math.round(((baseAmount * plr.ClickMultiplier.Value) * plr.PetMultiplier.Value) * plr:FindFirstChild("Multiplier").Value) * plr:WaitForChild("RankMultiplier").Value
	end
end)

NOTE: The print on line 3 prints correctly. It is just performing + - * or / on it that it causing the problem

1 Like

The kind of numbers I’m dealing with is like 10e20

The max number roblox can work with is 2^63 - 1, or a signed 64-bit integer. This is equivalent to 9.22337204e18. 10e20 is much larger than this and isn’t supported in lua. Counting higher than this causes an integer overflow error

My mistake, I was specifying int64.

So, there is no way to counter this?

The max number in lua is 1.7 × 10^308 which your number falls into, you’re not specifying int64 are you?

All the value used are number values not int values if that’s what you mean

If you are using the actual NumberValue class, then this is what the docs say:

A NumberValue is an object whose purpose is to store a single Lua number, defined to be double-precision floating point number, or more commonly known as a double . This stores a number in 64 bits (8 bytes) using the IEEE 754 representation (1 sign bit, 11 exponent bits and 52 fractional bits). The maximum numerical value that may be stored is 2^53, or 9,007,199,254,740,992, and the minimum is -9,007,199,254,740,992. It stores up to 15 digits of precision.

https://developer.roblox.com/en-us/api-reference/class/NumberValue

Oh I see, the max value is 2^53.

In this case, what should I do to go over the limit for number values

maybe add a second value convert it to a string? and make a system that does the addition algorthm eg(100
50 +
-----
)