package com.netflix.hollow;

import java.text.DecimalFormat;

public class HollowDiffUtil {
    private static final String[] HEAP_SIZE_UNITS = new String[] { "B", "KB", "MB", "GB", "TB" };
    public static String formatBytes(long sizeInBytes) {
        if(sizeInBytes <= 0) return "0";
        int digitGroups = (int) (Math.log10(sizeInBytes)/Math.log10(1024));
        return new DecimalFormat("#,##0.#").format(sizeInBytes/Math.pow(1024, digitGroups)) + " " + HEAP_SIZE_UNITS[digitGroups];
    }
}

@@ -183,16 +183,103 @@
 %22TB%22 %7D;%0A
+    private static final DecimalFormat BYTE_FORMATTER = new DecimalFormat(%22#,##0.#%22);%0A%0A
     publ
@@ -335,18 +335,30 @@
         
-if
+String sign = 
 (sizeInB
@@ -367,25 +367,69 @@
 es %3C
-=
  0) 
-return
+? %22-%22 :
  %22
-0
 %22;%0A
+        sizeInBytes = Math.abs(sizeInBytes);%0A
     
@@ -519,36 +519,29 @@
 urn 
-new DecimalFormat(%22#,##0.#%22)
+sign + BYTE_FORMATTER
 .for

Support negative sizeInBytes