hey guys, I have a question. when working with extremely huge numbers, is there a special way to round the decimals? I cant figure out a way to do this. for example if i had a number in the trillions, EX: 1,234,567,890,654, with my script it would pop up as 1.234567890654T. Instead i would like it to pop nice and clean as 1.2T. how could this be done and implemented into my current script? (Script Below)
Coins.Changed:Connect(function()
if Coins.Value >=10^6 and Coins.Value < 10^9 then
script.Parent.CoinFrame.Amount.Text = Coins.Value/10^6 .. "M"
elseif Coins.Value >= 10^9 and Coins.Value <10^12 then
script.Parent.CoinFrame.Amount.Text = Coins.Value/10^9 .. "B"
elseif Coins.Value >= 10^12 and Coins.Value <10^15 then
script.Parent.CoinFrame.Amount.Text = Coins.Value/10^12 .. "T"
elseif Coins.Value >= 10^15 and Coins.Value <10^18 then
script.Parent.CoinFrame.Amount.Text = Coins.Value/10^15 .. "Q"
end
end)
tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
the % in the string.format is just a format specifier, so it starts with that
then after it is the . and number which is the precision and when you use it with the “f” it will print the number of digits after the .
tonumber() then converts the string to a number
if you want to read more string | Documentation - Roblox Creator Hub