[Resolved] rounding to the nearest hundredth

So I have a formula that does a calculation and sometimes I’ll get a lot of decimal places. Is it possible to have the number calculated by the formula to only show up to the hundredth or thousandth place? I looked at math.floor but I don’t understand it well enough to tell if that will do what I want. Any help is much appreciated! [import]uid: 35535 topic_id: 31353 reply_id: 331353[/import]

I ended up using

[lua]function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end[/lua]

which i got from http://lua-users.org/wiki/SimpleRound.
I stuck that in my main.lua. If you do that then any time you need to round a number it’s as easy as:

[lua] myNumber = round(myNumber)[/lua] [import]uid: 147305 topic_id: 31353 reply_id: 125340[/import]

number=1.2345678
number=math.round(number*100)/100 –

I ended up using

[lua]function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end[/lua]

which i got from http://lua-users.org/wiki/SimpleRound.
I stuck that in my main.lua. If you do that then any time you need to round a number it’s as easy as:

[lua] myNumber = round(myNumber)[/lua] [import]uid: 147305 topic_id: 31353 reply_id: 125340[/import]

number=1.2345678
number=math.round(number*100)/100 –