From fe4c609e699237f7b272c56506106153f363dcb2 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Mon, 25 Jan 2010 21:48:39 +0100 Subject: Another tiny refactoring. Ignore-this: 50e76f6d7eb97924b10842a597a00066 darcs-hash:20100125204839-1d908-d067391e30d3ba383d1172c4ce4d00bbc799d171.gz --- Plugins/Monitors/Disk.hs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'Plugins/Monitors/Disk.hs') diff --git a/Plugins/Monitors/Disk.hs b/Plugins/Monitors/Disk.hs index 76116fb..4f42218 100644 --- a/Plugins/Monitors/Disk.hs +++ b/Plugins/Monitors/Disk.hs @@ -78,14 +78,12 @@ formatDev path (dev, xs) = speedToStr :: Int -> Float -> String speedToStr n x - | n > 2 || x < 103 = show (rInt x) ++ units !! n - | x < 1024 = "0." ++ s2 ds ++ units !! (n + 1) - | otherwise = speedToStr (n + 1) (x / 1024) - where units = ["B", "K", "M", "T"] - rInt = round :: Float ->Integer + | n > 2 || x < 103 = show (round x :: Int) ++ units n + | x < 1024 = "0." ++ s2 (fst (floatToDigits 10 (x/1024))) ++ units (n+1) + | otherwise = speedToStr (n+1) (x/1024) + where units = (!!) ["B", "K", "M", "T"] s2 (a:b:_) = show a ++ show b s2 as = show (head as) ++ "0" - (ds, _) = floatToDigits 10 (x / 1024) runDisk' :: String -> [Float] -> Monitor String runDisk' tmp xs = do -- cgit v1.2.3