diff options
author | ubq323 <ubq323@ubq323.website> | 2022-08-04 03:19:27 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2022-08-04 03:19:27 +0100 |
commit | 885b9a7e81b34ab6a530f705ba70b98c11d57156 (patch) | |
tree | e9375b8253f580cb4e0997c6b0b144ffb4d82a5c | |
parent | a502e58c63fb560c534c4557f9561ad091e2ece1 (diff) |
chat
-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) |