List of utility methods to do Double Number Readable Format
String | humanBytes(double bytes) humanBytes formats bytes as a human readable string. int base = 1024; String[] pre = new String[] { "k", "m", "g", "t", "p", "e" }; String post = "b"; if (bytes < (long) base) { return String.format("%.2f b", bytes); int exp = (int) (Math.log(bytes) / Math.log(base)); int index = exp - 1; ... |
String | humanBytes(double value) human Bytes String suffix = " B"; if (value > 1024) { value /= 1024; suffix = " KB"; if (value > 1024) { value /= 1024; suffix = " MB"; ... |
String | humanReadableNumber(double n) human Readable Number if (n >= 1e9) { return String.format("%d billion", (Math.round(n / 1e9))); } else if (n >= 1e6) { return String.format("%d million", (Math.round(n / 1e6))); } else if (n >= 1e3) { return String.format("%d thousand", (Math.round(n / 1e3))); } else if (n >= 1) { return String.format("%d", (Math.round(n))); ... |
String | humanReadableUnits(double bytes, boolean internationalSystemOfUnits) human Readable Units int unit = internationalSystemOfUnits ? 1000 : 1024; if (bytes <= 0) { return ""; } else if (bytes < unit) { return "B"; int exp = (int) (Math.log(bytes) / Math.log(unit)); String pre = (internationalSystemOfUnits ? "kMGTPEZY" : "KMGTPEZY").charAt(exp - 1) + ""; ... |
String | humanSize(double size) human Size if (size >= (1L << 40)) return String.format("%.1fT", size / (1L << 40)); if (size >= (1L << 30)) return String.format("%.1fG", size / (1L << 30)); if (size >= (1L << 20)) return String.format("%.1fM", size / (1L << 20)); if (size >= (1L << 10)) return String.format("%.1fK", size / (1L << 10)); ... |
String | toMB(double inB) to MB if (inB < 0) return "-"; return String.format("%.0f", inB / (1024 * 1024)); |
double | toMB(double n) to MB return toKB(n) / 1024;
|