Maybe Calle was right?

This commit is contained in:
pingu 2023-10-16 19:10:17 +02:00
parent 2b72c64cb3
commit 1a04115133

View File

@ -78,15 +78,18 @@ select = withAttr (attrName "selected")
unitSize :: Integer -> String unitSize :: Integer -> String
unitSize s unitSize s
| fromInteger s / (k2^(3 :: Int)) >= 1 / 2 = | s3 >= 1 / 2 =
show (f $ fromInteger s / (k2^(3 :: Int))) ++ " GB" show (f s3) ++ " GB"
| fromInteger s / (k2^(2 :: Int)) >= 1 / 2 = | s2 >= 1 / 2 =
show (f $ fromInteger s / (k2^(2 :: Int))) ++ " MB" show (f s2) ++ " MB"
| fromInteger s / k2 >= 1 / 2 = | s1 >= 1 / 2 =
show (f $ fromInteger s / k2 ) ++ " KB" show (f s1) ++ " KB"
| otherwise = | otherwise =
show s ++ " B" show s ++ " B"
where k2 = 1024 :: Double 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 :: Double -> Double
f q = fromInteger (truncate $ q * 100) / 100 f q = fromInteger (truncate $ q * 100) / 100