Skip to content

Commit 3cae6c6

Browse files
committed
df: fix rounding for 3 digit numbers
Signed-off-by: Alexander Bakanovskii <[email protected]>
1 parent c81c450 commit 3cae6c6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/uu/df/src/blocks.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ pub(crate) fn to_magnitude_and_suffix(
105105
} else {
106106
let tenths_place = rem / (bases[i] / 10);
107107

108-
if rem % (bases[i] / 10) == 0 {
108+
if quot >= 100 && rem > 0 {
109+
format!("{}{suffix}", quot + 1)
110+
} else if rem % (bases[i] / 10) == 0 {
109111
format!("{quot}.{tenths_place}{suffix}")
110112
} else if tenths_place + 1 == 10 || quot >= 10 {
111113
let quot = quot + 1;

0 commit comments

Comments
 (0)