From 3912ff3aa3ef75f79ccc6ec014c4a691d0e3803b Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sun, 17 May 2020 23:45:21 +0200 Subject: [PATCH] helpers: use float for format_filesize() In format_filesize(), we really do want float division, in order to display the value correctly. For example, if there's a file with 45200000 bytes, that should be shown as 43.1 MB, not 43.0. Fix this by using proper float division here, not int division. Fixes: a5809723352c ("helpers: use // not / for division") Signed-off-by: Johannes Berg Reviewed-by: Rob Browning Tested-by: Rob Browning --- lib/bup/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py index d988685..5b0c458 100644 --- a/lib/bup/helpers.py +++ b/lib/bup/helpers.py @@ -445,7 +445,7 @@ def format_filesize(size): return "%d" % (size) exponent = int(math.log(size) // math.log(unit)) size_prefix = "KMGTPE"[exponent - 1] - return "%.1f%s" % (size // math.pow(unit, exponent), size_prefix) + return "%.1f%s" % (size / math.pow(unit, exponent), size_prefix) class NotOk(Exception): -- 2.39.2