From d86661503460b2cf2d62152e9b2c1627016353ea Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Sat, 31 Jan 2015 23:42:04 -0500 Subject: [PATCH] Trim averages to at most 2 decimal places --- tablizer.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tablizer.go b/tablizer.go index da78ea0..d12efdd 100644 --- a/tablizer.go +++ b/tablizer.go @@ -185,8 +185,10 @@ func checkScoreDelta(scoreRows *[]Row, deltaRows *[]Row) *[]Row { var avgStr string if u.Times > 0 { - var avg float64 = float64(u.LastScore - u.ScoreOffset) / float64(u.Times) - avgStr = strconv.FormatFloat(avg, 'f', -1, 32) + avg := float64(score - u.ScoreOffset) / float64(u.Times) + avgStr = fmt.Sprintf("%.2f", avg) + avgStr = strings.TrimRight(avgStr, "0") + avgStr = strings.TrimRight(avgStr, ".") } else { avgStr = "-" }