fix warnings

This commit is contained in:
Starbeamrainbowlabs 2022-09-17 23:42:46 +01:00
parent 763ae3db8d
commit 08d40c8780
No known key found for this signature in database
GPG Key ID: 1BE5172E637709C2
5 changed files with 8 additions and 6 deletions

@ -23,7 +23,7 @@ else
powtab = { 1 }
}
for b = 1, bit_local.bits - 1 do
bit_local.powtab[#bit_local.powtab + 1] = math.pow(2, b)
bit_local.powtab[#bit_local.powtab + 1] = 2 ^ b
end
end
@ -68,7 +68,7 @@ end
-- bit_local.bnot
if not bit_local.bnot then
bit_local.bnot = function(x)
return bit_local.bxor(x, math.pow((bit_local.bits or math.floor(math.log(x, 2))), 2) - 1)
return bit_local.bxor(x, (bit_local.bits or math.floor(math.log(x, 2)) ^ 2) - 1)
end
end

@ -8,6 +8,6 @@ function worldeditadditions.format.human_size(n, decimals)
local sizes = { "", "K", "M", "G", "T", "P", "E", "Y", "Z" }
local factor = math.floor((#tostring(n) - 1) / 3)
local multiplier = 10^(decimals or 0)
local result = math.floor(0.5 + (n / math.pow(1000, factor)) * multiplier) / multiplier
local result = math.floor(0.5 + (n / (1000 ^ factor)) * multiplier) / multiplier
return result .. sizes[factor+1]
end

@ -5,8 +5,8 @@ function worldeditadditions.round(num, numDecimalPlaces)
end
function worldeditadditions.hypotenuse(x1, y1, x2, y2)
local xSquare = math.pow(x1 - x2, 2);
local ySquare = math.pow(y1 - y2, 2);
local xSquare = (x1 - x2) ^ 2;
local ySquare = (y1 - y2) ^ 2;
return math.sqrt(xSquare + ySquare);
end

@ -4,7 +4,9 @@
-- This is needed because in Lua 5.1 it's the global unpack(), but in Lua 5.4
-- it's moved to table.unpack().
local function table_unpack(tbl, offset, count)
---@diagnostic disable-next-line: deprecated
if type(unpack) == "function" then
---@diagnostic disable-next-line: deprecated
return unpack(tbl, offset, count)
else
return table.unpack(tbl, offset, count)

@ -10,7 +10,7 @@ local function human_size(n, decimals)
local sizes = { "", "K", "M", "G", "T", "P", "E", "Y", "Z" }
local factor = math.floor((#tostring(n) - 1) / 3)
local multiplier = 10^(decimals or 0)
local result = math.floor(0.5 + (n / math.pow(1000, factor)) * multiplier) / multiplier
local result = math.floor(0.5 + (n / (1000 ^ factor)) * multiplier) / multiplier
return result .. sizes[factor+1]
end