Does what it says on the tin.

function round(what, precision) return math.floor(what*math.pow(10,precision)+0.5) / math.pow(10,precision) end

Advertisements

Skip to content
# Rounding to a certain number of decimal places in Lua

##
One thought on “Rounding to a certain number of decimal places in Lua”

### Leave a Reply

Does what it says on the tin.

function round(what, precision) return math.floor(what*math.pow(10,precision)+0.5) / math.pow(10,precision) end

Advertisements

%d bloggers like this:

[…] Since doing the screenshot, I have updated the plug-in after finding how to round to x decimal places in Lua: function round(what, precision) return […]