diff options
| author | Joey Hess <joeyh@joeyh.name> | 2017-05-20 09:28:22 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2017-05-20 09:28:22 -0400 |
| commit | 24e789a2ac981b3d4b2dfaf1af359c4407587a00 (patch) | |
| tree | e676038cd69b8ff91efc3b7b5a85e63aad5214d4 /src/Utility/DataUnits.hs | |
| parent | d499d8d668fa8ec32833edb4b7a5677dcbf75c56 (diff) | |
| parent | 3dd36f7e922b0dfdde54420a931e77fd02e6b83c (diff) | |
Merge branch 'joeyconfig' of ssh://propellor.branchable.com into joeyconfig
Diffstat (limited to 'src/Utility/DataUnits.hs')
| -rw-r--r-- | src/Utility/DataUnits.hs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Utility/DataUnits.hs b/src/Utility/DataUnits.hs index 6e40932e..a6c9ffcf 100644 --- a/src/Utility/DataUnits.hs +++ b/src/Utility/DataUnits.hs @@ -45,6 +45,7 @@ module Utility.DataUnits ( ByteSize, roughSize, + roughSize', compareSizes, readSize ) where @@ -109,7 +110,10 @@ oldSchoolUnits = zipWith (curry mingle) storageUnits memoryUnits {- approximate display of a particular number of bytes -} roughSize :: [Unit] -> Bool -> ByteSize -> String -roughSize units short i +roughSize units short i = roughSize' units short 2 i + +roughSize' :: [Unit] -> Bool -> Int -> ByteSize -> String +roughSize' units short precision i | i < 0 = '-' : findUnit units' (negate i) | otherwise = findUnit units' i where @@ -123,7 +127,7 @@ roughSize units short i showUnit x (Unit size abbrev name) = s ++ " " ++ unit where v = (fromInteger x :: Double) / fromInteger size - s = showImprecise 2 v + s = showImprecise precision v unit | short = abbrev | s == "1" = name |
