Software / code / prosody
Changeset
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 | 10889:25e0ec11b4e4 |
| children | 10891:8d47858805c9 |
| files | util/human/units.lua |
| diffstat | 1 files changed, 8 insertions(+), 0 deletions(-) [+] |
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,