X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=progress.c;h=621c34edc2a3a6a9bceb0f708ed5b0df05145fb5;hb=f90cf2b9203e81e3a2b70b15480628e9189b7e60;hp=55a8687ad15788f8ea5a5beb463d216908f618b2;hpb=87fb597d4e3643210e1967d1e3035f28f5b019e5;p=git.git diff --git a/progress.c b/progress.c index 55a8687ad..621c34edc 100644 --- a/progress.c +++ b/progress.c @@ -121,13 +121,13 @@ static void throughput_string(struct throughput *tp, off_t total, (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); }