Small improvement

pull/162/head
M66B 5 years ago
parent e058cc17d1
commit 0f9734c7bd

@ -387,12 +387,14 @@ public class Helper {
// Formatting
private static final DecimalFormat df = new DecimalFormat("@@");
static String humanReadableByteCount(long bytes, boolean si) {
int unit = si ? 1000 : 1024;
if (bytes < unit) return bytes + " B";
int exp = (int) (Math.log(bytes) / Math.log(unit));
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i");
return new DecimalFormat("@@").format(bytes / Math.pow(unit, exp)) + " " + pre + "B";
return df.format(bytes / Math.pow(unit, exp)) + " " + pre + "B";
}
// https://issuetracker.google.com/issues/37054851

Loading…
Cancel
Save