mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-09 18:43:23 +02:00
Format negative number of bytes
This commit is contained in:
@@ -1201,11 +1201,16 @@ public class Helper {
|
||||
}
|
||||
|
||||
private static String humanReadableByteCount(long bytes, boolean si) {
|
||||
int unit = si ? 1000 : 1024;
|
||||
if (bytes < unit) return bytes + " B";
|
||||
int sign = (int) Math.signum(bytes);
|
||||
bytes = Math.abs(bytes);
|
||||
|
||||
int unit = (si ? 1000 : 1024);
|
||||
if (bytes < unit)
|
||||
return sign * bytes + " B";
|
||||
|
||||
int exp = (int) (Math.log(bytes) / Math.log(unit));
|
||||
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i");
|
||||
return df.format(bytes / Math.pow(unit, exp)) + " " + pre + "B";
|
||||
return df.format(sign * bytes / Math.pow(unit, exp)) + " " + pre + "B";
|
||||
}
|
||||
|
||||
static boolean isPrintableChar(char c) {
|
||||
|
||||
Reference in New Issue
Block a user