summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/openslx/util/Util.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/main/java/org/openslx/util/Util.java b/src/main/java/org/openslx/util/Util.java
index 2ebd4e1..e425083 100644
--- a/src/main/java/org/openslx/util/Util.java
+++ b/src/main/java/org/openslx/util/Util.java
@@ -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] );
}