summaryrefslogtreecommitdiff
path: root/chat.lua
diff options
context:
space:
mode:
Diffstat (limited to 'chat.lua')
-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)