From 87cf842c28a58620f388344099b636a537ffc457 Mon Sep 17 00:00:00 2001 From: Flameshadowxeroshin Date: Sun, 12 Dec 2010 15:34:47 -0600 Subject: [PATCH] Add math.round. --- Themes/_fallback/Scripts/03 ProductivityHelpers.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Themes/_fallback/Scripts/03 ProductivityHelpers.lua b/Themes/_fallback/Scripts/03 ProductivityHelpers.lua index 41942df216..800303f672 100644 --- a/Themes/_fallback/Scripts/03 ProductivityHelpers.lua +++ b/Themes/_fallback/Scripts/03 ProductivityHelpers.lua @@ -241,5 +241,12 @@ function pname(pn) return ToEnumShortString(pn) end +function math.round(num, pre) + if pre and pre < 0 then pre = 0 end + local mult = 10^(pre or 0) + if num >= 0 then return math.floor(num*mult+.5)/mult + else return math.ceil(num*mult-.5)/mult end +end + --[[ end helper functions ]] --- this code is in the public domain. \ No newline at end of file +-- this code is in the public domain.