This commit is contained in:
2025-02-12 23:37:34 +09:00
parent f5d23e9a07
commit 63345c753c

View File

@@ -20,8 +20,8 @@ local font_color = {
["negative"] = { r = 1, g = 0.3, b = 0.3 }, ["negative"] = { r = 1, g = 0.3, b = 0.3 },
} }
local function format_n(n) local function format_n(amount)
if n < 0.1 then if amount < 0.1 then
return "0.0" return "0.0"
end end
@@ -34,15 +34,15 @@ local function format_n(n)
} }
for letter, limit in pairs(suffix_list) do for letter, limit in pairs(suffix_list) do
if math.abs(n) >= limit then if math.abs(amount) >= limit then
n = string.format("%.2f", n / limit) amount = string.format("%.1f", amount / limit)
suffix = letter suffix = letter
break break
end end
end end
local k local k
local formatted = n local formatted = amount
while true do while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", "%1,%2") formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", "%1,%2")