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

how would I round to the nearest?

Asked by 9 years ago

I am trying to make a function that will round a given value to the nearest given second number. I'll admit it, today my brain kinda broke. If anyone could give me a hand with some simple math, I would appreciate it.

function calcround(number,inc) 
    return math.floor(number/inc + (inc / .25)) * inc
end

print(calcround(31.75,1))
0
Define 'nearest second number'. Perci1 4988 — 9y

Answer this question