I've been trying to write a function that rounds a number to the multiple of 4 with the least absolute distance from the number. How do I do this?
I honestly have absolutely no clue how to do this, please help me.
I've been trying to write a function that rounds a number to the multiple of 4 with the least absolute distance from the number. How do I do this?
I honestly have absolutely no clue how to do this, please help me.
You can use this simple script :)
function Round(Number,Nearest)
return math.floor(Number/Nearest + 0.5)*Nearest
end
Round(321,4)
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Sweet, thanks!
Please provide an explanation with your answers. https://scriptinghelpers.org/help/how-post-good-questions-answers