summaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2017-06-02 16:11:31 +0200
committerAndrew Lewis <nerf@judo.za.org>2017-06-02 16:11:31 +0200
commit865633cdcbbc3e3cba52b38dc6562bb40a909c87 (patch)
tree39f810b9291ab472a1378101371ff8bc6744f02d /lualib
parentc1184c7823b41ee51750d7551403bbd9499a71ff (diff)
downloadrspamd-865633cdcbbc3e3cba52b38dc6562bb40a909c87.tar.gz
rspamd-865633cdcbbc3e3cba52b38dc6562bb40a909c87.zip
[Minor] Metadata exporter: score should be number
Diffstat (limited to 'lualib')
-rw-r--r--lualib/lua_util.lua6
1 files changed, 6 insertions, 0 deletions
diff --git a/lualib/lua_util.lua b/lualib/lua_util.lua
index 2ae4e69b1..81e4cb606 100644
--- a/lualib/lua_util.lua
+++ b/lualib/lua_util.lua
@@ -24,4 +24,10 @@ exports.rspamd_str_trim = function(s)
return match(ptrim, s)
end
+-- Robert Jay Gould http://lua-users.org/wiki/SimpleRound
+exports.round = function(num, numDecimalPlaces)
+ local mult = 10^(numDecimalPlaces or 0)
+ return math.floor(num * mult + 0.5) / mult
+end
+
return exports