Mercurial > prosody-hg
diff util/human/units.lua @ 10890:a451f80d1cea
util.human.units: Handle lack of math.log(n, base) on Lua 5.1
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 03 Jun 2020 20:17:33 +0200 |
| parents | 25e0ec11b4e4 |
| children | c5f26f9adb31 |
line wrap: on
line diff
--- a/util/human/units.lua Wed Jun 03 20:16:00 2020 +0200 +++ b/util/human/units.lua Wed Jun 03 20:17:33 2020 +0200 @@ -6,6 +6,14 @@ local math_min = math.min; local unpack = table.unpack or unpack; --luacheck: ignore 113 +if math_log(10, 10) ~= 1 then + -- Lua 5.1 COMPAT + local log10 = math.log10; + function math_log(n, base) + return log10(n) / log10(base); + end +end + local large = { "k", 1000, "M", 1000000,
