Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7230174 authored by Roozbeh Pournader's avatar Roozbeh Pournader
Browse files

Make FormatBytes() not use decimal points for size <= 900.

Previously, values like 0 were being formatted like "0.00 B".

Bug: 11237727
Change-Id: Ia90ae0a2cde9fa5993fa9b5b131f38b56f9dc34a
parent 012d014c
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -131,7 +131,10 @@ public final class Formatter {
        // floating point errors.
        final int roundFactor;
        final String roundFormat;
        if (result < 1) {
        if (mult == 1 || result >= 100) {
            roundFactor = 1;
            roundFormat = "%.0f";
        } else if (result < 1) {
            roundFactor = 100;
            roundFormat = "%.2f";
        } else if (result < 10) {
@@ -142,7 +145,7 @@ public final class Formatter {
                roundFactor = 100;
                roundFormat = "%.2f";
            }
        } else if (result < 100) {
        } else { // 10 <= result < 100
            if ((flags & FLAG_SHORTER) != 0) {
                roundFactor = 1;
                roundFormat = "%.0f";
@@ -150,9 +153,6 @@ public final class Formatter {
                roundFactor = 100;
                roundFormat = "%.2f";
            }
        } else {
            roundFactor = 1;
            roundFormat = "%.0f";
        }
        final String roundedString = String.format(roundFormat, result);