diff options
Diffstat (limited to 'src/main/java/org/openslx/util/Util.java')
-rw-r--r-- | src/main/java/org/openslx/util/Util.java | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/main/java/org/openslx/util/Util.java b/src/main/java/org/openslx/util/Util.java index 5300cfa..e425083 100644 --- a/src/main/java/org/openslx/util/Util.java +++ b/src/main/java/org/openslx/util/Util.java @@ -147,7 +147,7 @@ public class Util */ public static long tickCount() { - return System.nanoTime() / 1000; + return System.nanoTime() / 1000_000; } private static final String[] UNITS = new String[] { "B", "KB", "MB", "GB", "TB", "PB", "???" }; @@ -155,11 +155,12 @@ public class Util public static String formatBytes( double val ) { int unit = 0; - while ( val > 1024 ) { + while ( Math.abs(val) > 1024 ) { val /= 1024; unit++; - if (unit >= UNITS.length) - break; + } + if (unit >= UNITS.length) { + unit = UNITS.length - 1; } return String.format( "%.1f %s", val, UNITS[unit] ); } |