Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to round off number into 2 decimals?

I have a simple script which show's the humanoid data such as JumpPower and WalkingSpeed. My problem is that if the value show more than 2 decimals then the Gui can't show it.

What I need is something that only show 2 decimals, I hope you guys understand what I mean.

1 answer

✓ Accepted answer

you can try these

local Value = 37.7777779

local rounded_down = math.floor(Value*100)/100 --Result: 37.77
local rounded_up = math.ceil(Value*100)/100 --Result: 37.78
local nearest = math.round(Value*100)/100 --Result: 37.78
print(rounded_down)
print(rounded_up)
print(nearest)

4 comments

0

Does the number only show 2 decimals? What if I want to show 3 decimals? I'm just curious this time. Btw thank you.

0

change 100 to 1000 if you run it in a lua interpreter the numbers will shift

0

Oww, thanks once again

0

:D

This discussion is preserved as it was. New answers, comments, and votes are closed.