From 885b9a7e81b34ab6a530f705ba70b98c11d57156 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 4 Aug 2022 03:19:27 +0100 Subject: chat --- chat.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/chat.lua b/chat.lua index 4c38e16..d347f68 100644 --- a/chat.lua +++ b/chat.lua @@ -47,10 +47,12 @@ local function round_dp(n,dp) return round(n*exp)/exp end -local function sci(x) +local function sci(n) + if n == 0 then return n end + local x = math.abs(n) local b = math.floor(math.log10(x)) local a = round_dp(x/10^b,2) - return a.."e"..b + return (n<0 and "-" or "")..a.."e"..b end local function maybe_sci(x) -- cgit v1.2.3