Minetest-WorldEditAdditions/worldeditadditions/utils/numbers.lua

6 lines
194 B
Lua
Raw Normal View History

2020-05-11 03:02:02 +02:00
-- From http://lua-users.org/wiki/SimpleRound
2020-05-12 01:38:42 +02:00
function worldeditadditions.round(num, numDecimalPlaces)
2020-05-11 03:02:02 +02:00
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end