How do I round numbers on decimals
you can just do
print(Module.AbbreviateN(math.round(1.00000001e23)))
also I recommend you use string.format for doing this since sometimes it might add extra decimals due to a new update. Do prevent this you can do
print(Module.AbbreviateN(tonumber(string.format("%.f", 1.00000001e23))))
Wont help me. I divide the numbers meaning 123456 would return 123.456.
Meaning .456 are decimals and this just rounds it up or down. 123.456 would turn into 123
if you dont want it to round up/down use math.floor when it’s returning the value
I’m not trying to round the number or floor it.
I’m trying to round on decimals so let’s say it returns 123.45681 then it’d round to 123.456
math.round removes decimals. doesn’t round it(im pretty sure). try it.
I’m not trying to remove the decimals I’m trying to round on decimals for example:
AbbreviateN(123456) -- Returns 123.456
but if I do
AbbreviateN(1000001) -- Returns 1.000, because the last digits is a 1
I’m trying to round on decimals if digit number 4, 5 or 6 is greater than 0 like so
AbbreviateN(1200000) -- 1.2m Correct
AbbreviateN(1230000) -- 1.23m Correct
AbbreviateN(1231000) -- 1.231m Correct
AbbreviateN(1000001) -- 1.000m Incorrect, because I'm using string.sub it wont round on decimals
Edit: I’ve found a solution and summarised my code.