summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2022-10-04 08:10:36 -0400
committerAndrew Cady <d@jerkface.net>2022-10-04 08:10:36 -0400
commitc21e1ae848dab89bc3da7147d3ab57ef2c8743e5 (patch)
tree62151888deb46245ddc1600c2543ce16fc692b58
parent3a58f9206674abd3c57197bdc05655fa5ba3acc8 (diff)
hide decimal places that are 0s
-rwxr-xr-xrepgoal.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/repgoal.hs b/repgoal.hs
index d8624e5..2170073 100755
--- a/repgoal.hs
+++ b/repgoal.hs
@@ -95,7 +95,9 @@ computeOneRepMax :: Performance -> Rational
95computeOneRepMax Achieved{..} = achievedWeight * (realToFrac achievedReps * 0.0333 + 1) 95computeOneRepMax Achieved{..} = achievedWeight * (realToFrac achievedReps * 0.0333 + 1)
96 96
97showRational :: Rational -> String 97showRational :: Rational -> String
98showRational = printf "%.3f" . (realToFrac :: Rational -> Float) 98showRational n = printf format $ (realToFrac :: Rational -> Float) $ n
99 where
100 format = if floor (n * 10) `mod` 10 == (0 :: Integer) then "%.0f" else "%.2f"
99 101
100drawUI :: () -> [Widget ()] 102drawUI :: () -> [Widget ()]
101drawUI () = [a] 103drawUI () = [a]