Display byte sizes with more precision.

This commit is contained in:
Joey Hess 2013-07-19 12:21:44 -04:00
parent e2451fec18
commit 647a938f6a
2 changed files with 12 additions and 4 deletions

View file

@ -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

1
debian/changelog vendored
View file

@ -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