Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I round a value to the nearest .01?

Asked by 7 years ago

I've been looking all over the wiki, yet I can't seem to figure out how to round down a value to the nearest .01. This is the portion of my script where I attempted to round the value:

math.floor((tick() - start)*100/100)

However, when printed the value still turns out as a whole number. Any help would be appreciated.

1 answer

Log in to vote
1
Answered by 7 years ago

Instead of putting the *100/100 inside of the same operation, maybe try:

math.floor((tick() - start)*100)/100

This is because math.floor will always round to the nearest integer, but that integer can only be manipulated from outside the math.floor() function.

0
Thanks, it should've been obvious for me, not sure why it passed right over my head. This worked perfectly. GotSanity 16 — 7y
0
Glad to hear it. superwar55 48 — 7y
Ad

Answer this question