1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Fix a bug in the KiB and MiB computation in add_xnum_to_string

where the fractional part overflowed to 0 before the integer part
was incremented.

Thanks to Marti Raudsepp for finding this bug and Marti and pasky
for the fix.
This commit is contained in:
Marti Raudsepp 2005-10-16 01:53:06 +00:00 committed by Miciah Dashiel Butler Masters
commit e31a66745a
2 changed files with 5 additions and 2 deletions

View File

@ -337,6 +337,9 @@ Martin Kavalec <martin@penguin.cz>
Martin Norback <d95mback@dtek.chalmers.se>
Swedish translation
Marti Raudsepp <marti@juffo.org>
KiB/MiB computation bugfix
Matthew Mueller <donut@azstarnet.com>
Random hacking

View File

@ -176,12 +176,12 @@ add_xnum_to_string(struct string *string, off_t xnum)
/* Mebi (Mi), 2^20 */
if (xnum >= 1024 * 1024) {
suff[0] = 'M';
d = (xnum / (int) ((int) (1024 * 1024) / (int) 10)) % 10;
d = (xnum * (int) 10 / (int) ((int) (1024 * 1024))) % 10;
xnum /= 1024*1024;
/* Kibi (Ki), 2^10 */
} else if (xnum >= 1024) {
suff[0] = 'K';
d = (xnum / (int) ((int) 1024 / (int) 10)) % 10;
d = (xnum * (int) 10 / (int) 1024) % 10;
xnum /= 1024;
}