diff options
-rw-r--r-- | Utility/DataUnits.hs | 15 | ||||
-rw-r--r-- | debian/changelog | 1 |
2 files changed, 12 insertions, 4 deletions
diff --git a/Utility/DataUnits.hs b/Utility/DataUnits.hs index c6990fdfb..e5c2fc83e 100644 --- a/Utility/DataUnits.hs +++ b/Utility/DataUnits.hs @@ -116,12 +116,19 @@ roughSize units abbrev i | otherwise = findUnit us i' findUnit [] i' = showUnit i' (last units') -- bytes - showUnit i' (Unit s a n) = let num = chop i' s in - show num ++ " " ++ + showUnit i' (Unit s a n) = let (num, decimal) = chop i' s in + show num ++ decimal ++ " " ++ (if abbrev then a else plural num n) - chop :: Integer -> Integer -> Integer - chop i' d = round $ (fromInteger i' :: Double) / fromInteger d + chop :: Integer -> Integer -> (Integer, String) + chop i' d = + let (num, decimal) = properFraction $ (fromInteger i' :: Double) / fromInteger d + dnum = round (decimal * 100) :: Integer + ds = show dnum + ds' = (take (2 - length ds) (repeat '0')) ++ ds + in if (dnum == 0) + then (num, "") + else (num, "." ++ ds') plural n u | n == 1 = u diff --git a/debian/changelog b/debian/changelog index b74fb33c9..cecf996d2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,7 @@ git-annex (4.20130710) UNRELEASED; urgency=low proceed on to the next file, rather than dying. * Fix checking when content is present in a non-bare repository accessed via http. + * Display byte sizes with more precision. -- Joey Hess <joeyh@debian.org> Tue, 09 Jul 2013 19:17:13 -0400 |