diff options
Diffstat (limited to 'chat.lua')
-rw-r--r-- | chat.lua | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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) |