Maybe Calle was right?
This commit is contained in:
parent
2b72c64cb3
commit
1a04115133
15
app/Main.hs
15
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"
|
||||
| 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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user