From 308a29d80942d5101a3bcaf45a684ebccd2eed26 Mon Sep 17 00:00:00 2001 From: Jameson Lee Date: Thu, 16 Aug 2018 00:26:07 -0700 Subject: [PATCH] switch to scientific notation, AAAAAAPPPPLLLLEEEE!!!! --- yahoo_quotes.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/yahoo_quotes.go b/yahoo_quotes.go index 6771432..371e832 100644 --- a/yahoo_quotes.go +++ b/yahoo_quotes.go @@ -242,14 +242,17 @@ func sanitize(body []byte) []byte { func float2Str(v float64) string { unit := "" switch { - case v > 1000000000.0: - v = v / 1000000000.0 + case v > 1.0e12: + v = v / 1.0e12 + unit = "T" + case v > 1.0e9: + v = v / 1.0e9 unit = "B" - case v > 1000000.0: - v = v / 1000000.0 + case v > 1.0e6: + v = v / 1.0e6 unit = "M" - case v > 1000.0: - v = v / 1000.0 + case v > 1.0e5: + v = v / 1.0e3 unit = "K" default: unit = ""