fix warnings

This commit is contained in:
Starbeamrainbowlabs 2022-09-17 23:42:46 +01:00
parent 763ae3db8d
commit 08d40c8780
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
5 changed files with 8 additions and 6 deletions

View File

@ -23,7 +23,7 @@ else
powtab = { 1 } powtab = { 1 }
} }
for b = 1, bit_local.bits - 1 do 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
end end
@ -68,7 +68,7 @@ end
-- bit_local.bnot -- bit_local.bnot
if not bit_local.bnot then if not bit_local.bnot then
bit_local.bnot = function(x) 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
end end

View File

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

View File

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

View File

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

View File

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