# HG changeset patch # User Kim Alvefur # Date 1591208253 -7200 # Node ID a451f80d1cea85a959b55ca507ee93b2d8ad0778 # Parent 25e0ec11b4e4707ae12e5ca827d98513063f4abe util.human.units: Handle lack of math.log(n, base) on Lua 5.1 diff -r 25e0ec11b4e4 -r a451f80d1cea util/human/units.lua --- 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,