1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

[svn] Divide with 1024 instead of shifting by ten places.

This commit is contained in:
hniksic 2005-06-25 14:16:51 -07:00
parent da084a2979
commit bc4c82c615
2 changed files with 8 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2005-06-25 Hrvoje Niksic <hniksic@xemacs.org>
* utils.c (human_readable): Divide with 1024 instead of shifting
so the operation can work with non-integer N.
2005-06-25 Hrvoje Niksic <hniksic@xemacs.org> 2005-06-25 Hrvoje Niksic <hniksic@xemacs.org>
* progress.c (eta_to_human): New logic for more human-readable * progress.c (eta_to_human): New logic for more human-readable

View File

@ -1275,11 +1275,11 @@ human_readable (wgint n)
/* At each iteration N is greater than the *subsequent* power. /* At each iteration N is greater than the *subsequent* power.
That way N/1024.0 produces a decimal number in the units of That way N/1024.0 produces a decimal number in the units of
*this* power. */ *this* power. */
if ((n >> 10) < 1024 || i == countof (powers) - 1) if ((n / 1024) < 1024 || i == countof (powers) - 1)
{ {
/* Must cast to long first because MS VC can't directly cast /* Must cast to long first because MS VC can't directly cast
__int64 to double. (This is safe because N is known to __int64 to double. (This is safe because N is known to
be <2**20.) */ be < 1024^2, so always fits into long.) */
double val = (double) (long) n / 1024.0; double val = (double) (long) n / 1024.0;
/* Print values smaller than 10 with one decimal digits, and /* Print values smaller than 10 with one decimal digits, and
others without any decimals. */ others without any decimals. */
@ -1287,7 +1287,7 @@ human_readable (wgint n)
val < 10 ? 1 : 0, val, powers[i]); val < 10 ? 1 : 0, val, powers[i]);
return buf; return buf;
} }
n >>= 10; n /= 1024;
} }
return NULL; /* unreached */ return NULL; /* unreached */
} }