summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f29ac4f)
raw | patch | inline | side by side (parent: f29ac4f)
author | Nicolas Pitre <nico@cam.org> | |
Fri, 24 Apr 2009 21:46:15 +0000 (17:46 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 25 Apr 2009 15:54:18 +0000 (08:54 -0700) |
Often the throughput output is requested when the data read so far is
one smaller than multiple of 1024; because 1023/1024 is ~0.999, it often
shows up as 0.99 because the code currently truncates.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
one smaller than multiple of 1024; because 1023/1024 is ~0.999, it often
shows up as 0.99 because the code currently truncates.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
progress.c | patch | blob | history |
diff --git a/progress.c b/progress.c
index 55a8687ad15788f8ea5a5beb463d216908f618b2..621c34edc2a3a6a9bceb0f708ed5b0df05145fb5 100644 (file)
--- a/progress.c
+++ b/progress.c
(int)(total >> 30),
(int)(total & ((1 << 30) - 1)) / 10737419);
} else if (total > 1 << 20) {
+ int x = total + 5243; /* for rounding */
l -= snprintf(tp->display, l, ", %u.%2.2u MiB",
- (int)(total >> 20),
- ((int)(total & ((1 << 20) - 1)) * 100) >> 20);
+ x >> 20, ((x & ((1 << 20) - 1)) * 100) >> 20);
} else if (total > 1 << 10) {
+ int x = total + 5; /* for rounding */
l -= snprintf(tp->display, l, ", %u.%2.2u KiB",
- (int)(total >> 10),
- ((int)(total & ((1 << 10) - 1)) * 100) >> 10);
+ x >> 10, ((x & ((1 << 10) - 1)) * 100) >> 10);
} else {
l -= snprintf(tp->display, l, ", %u bytes", (int)total);
}