Comma function returns odd decimal number

Hello, I’m currently having issues with giving large numbers commas. I use this function for it:

return function(number)
	local i, j, minus, int, fraction = tostring(number):find('([-]?)(%d+)([.]?%d*)')

	int = int:reverse():gsub("(%d%d%d)", "%1,")

	return minus .. int:reverse():gsub("^,", "") .. fraction
end

(This is a module script btw)

It works perfectly fine, however, once I reach this specific number: 1,000,000,000,000,000,000,000 (1se) it just breaks and returns this odd decimal number (Btw the decimal matches the whole number, but for some reason there is a decimal after the first 2)
MoneyReturnVal

Any help would be appreciated, thanks!

Once you go over roughly 10^20 there is a transition between integers and floats. Try printing just tostring(10^20) and tostring(10^21) you’ll see the difference.

1 Like

Hey everyone I figured out the issue with a friend of mine and the issue was that roblox automatically converters numbers above 1septillion to have scientific notations. For anyone who is also stumped on this issue just add this to the number string.format("%.f",x) and it will remove the scientific notations.