summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2022-08-04 03:19:27 +0100
committerubq323 <ubq323@ubq323.website>2022-08-04 03:19:27 +0100
commit885b9a7e81b34ab6a530f705ba70b98c11d57156 (patch)
treee9375b8253f580cb4e0997c6b0b144ffb4d82a5c
parenta502e58c63fb560c534c4557f9561ad091e2ece1 (diff)
chat
-rw-r--r--chat.lua6
1 files 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)