сукаблядь

This commit is contained in:
Igor Timofeev
2016-11-13 20:07:34 +03:00
parent e7a9412d11
commit 785bf1b19c
16 changed files with 773 additions and 376 deletions

View File

@@ -76,7 +76,11 @@ bit32.numberFromByteArray = bit32.byteArrayToNumber
-------------------------------------------------- Math extensions --------------------------------------------------
function math.round(num)
if num >= 0 then return math.floor(num + 0.5) else return math.ceil(num - 0.5) end
if num >= 0 then
return math.floor(num + 0.5)
else
return math.ceil(num - 0.5)
end
end
function math.roundToDecimalPlaces(num, decimalPlaces)
@@ -85,18 +89,31 @@ function math.roundToDecimalPlaces(num, decimalPlaces)
end
function math.getDigitCount(num)
local count = 0
while number > 0 do
number = math.floor(number / 10)
count = count + 1
end
return count
return num == 0 and 1 or math.ceil(math.log(num + 1, 10))
end
function math.doubleToString(num, digitCount)
return string.format("%." .. (digitCount or 1) .. "f", num)
end
function math.shortenNumber(number, digitCount)
local shortcuts = {
"K",
"M",
"B",
"T"
}
local index = math.floor(math.log(number, 1000))
if number < 1000 then
return number
elseif index > #shortcuts then
index = #shortcuts
end
return math.roundToDecimalPlaces(number / 1000 ^ index, digitCount) .. shortcuts[index]
end
-------------------------------------------------- Table extensions --------------------------------------------------
local function doSerialize(array, text, prettyLook, indentationSymbol, oldIndentationSymbol, equalsSymbol, currentRecusrionStack, recursionStackLimit)