free.c - name correctly the binary multiples in the human-readable case

This commit is contained in:
getzze 2016-11-04 01:11:01 +00:00 committed by Craig Small
parent 77590f75a1
commit ff700abc72

27
free.c
View File

@ -152,14 +152,25 @@ static const char *scale_size(unsigned long size, int flags, struct commandline_
case 4: case 4:
case 5: case 5:
case 6: case 6:
if (4 >= if (!(flags & FREE_SI)) {
snprintf(buf, sizeof(buf), "%.1f%c", if (5 >=
(float)((size / 1024) * base / power(base, i - 2)), *up)) snprintf(buf, sizeof(buf), "%.1f%ci",
return buf; (float)((size / 1024) * base / power(base, i - 2)), *up))
if (4 >= return buf;
snprintf(buf, sizeof(buf), "%ld%c", if (5 >=
(long)((size / 1024) * base / power(base, i - 2)), *up)) snprintf(buf, sizeof(buf), "%ld%ci",
return buf; (long)((size / 1024) * base / power(base, i - 2)), *up))
return buf;
} else {
if (4 >=
snprintf(buf, sizeof(buf), "%.1f%c",
(float)((size / 1024) * base / power(base, i - 2)), *up))
return buf;
if (4 >=
snprintf(buf, sizeof(buf), "%ld%c",
(long)((size / 1024) * base / power(base, i - 2)), *up))
return buf;
}
break; break;
case 7: case 7:
break; break;