diff --git a/app/Main.hs b/app/Main.hs index 81a0c9f..580ade8 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -78,15 +78,18 @@ select = withAttr (attrName "selected") unitSize :: Integer -> String unitSize s - | fromInteger s / (k2^(3 :: Int)) >= 1 / 2 = - show (f $ fromInteger s / (k2^(3 :: Int))) ++ " GB" - | fromInteger s / (k2^(2 :: Int)) >= 1 / 2 = - show (f $ fromInteger s / (k2^(2 :: Int))) ++ " MB" - | fromInteger s / k2 >= 1 / 2 = - show (f $ fromInteger s / k2 ) ++ " KB" - | otherwise = - show s ++ " B" + | s3 >= 1 / 2 = + show (f s3) ++ " GB" + | s2 >= 1 / 2 = + show (f s2) ++ " MB" + | s1 >= 1 / 2 = + show (f s1) ++ " KB" + | otherwise = + show s ++ " B" where k2 = 1024 :: Double + s3 = fromInteger s / (k2^(3 :: Int)) + s2 = fromInteger s / (k2^(2 :: Int)) + s1 = fromInteger s / (k2^(1 :: Int)) f :: Double -> Double f q = fromInteger (truncate $ q * 100) / 100