From c21e1ae848dab89bc3da7147d3ab57ef2c8743e5 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Tue, 4 Oct 2022 08:10:36 -0400 Subject: hide decimal places that are 0s --- repgoal.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'repgoal.hs') 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 computeOneRepMax Achieved{..} = achievedWeight * (realToFrac achievedReps * 0.0333 + 1) showRational :: Rational -> String -showRational = printf "%.3f" . (realToFrac :: Rational -> Float) +showRational n = printf format $ (realToFrac :: Rational -> Float) $ n + where + format = if floor (n * 10) `mod` 10 == (0 :: Integer) then "%.0f" else "%.2f" drawUI :: () -> [Widget ()] drawUI () = [a] -- cgit v1.2.3