/** * @param value * @return string */ public static final String toBytes(final double value) { if (value < 1000L) { if (value < 0) { return '-' + Format.Compact.toBytes(-value); } if (value >= 1) { return Compact.FORMATTER.format2(value) + ' '; } if (value >= Format.DOUBLE_MILLI) { return Compact.FORMATTER.format2(value / Format.DOUBLE_MILLI_BYTES) + " ml"; } if (value >= Format.DOUBLE_MICRO) { return Compact.FORMATTER.format2(value / Format.DOUBLE_MICRO_BYTES) + " mk"; } return Compact.FORMATTER.format2(value / Format.DOUBLE_NANO_BYTES) + " n"; } if (value >= 1000L * 1000L * 1000L * 1000L) { return Compact.FORMATTER.format2(value / Format.DOUBLE_TERA_BYTES) + " T"; } if (value >= 1000L * 1000L * 1000L) { return Compact.FORMATTER.format2(value / Format.DOUBLE_GIGA_BYTES) + " G"; } if (value >= 1000L * 1000L) { return Compact.FORMATTER.format2(value / Format.DOUBLE_MEGA_BYTES) + " M"; } if (value >= 1000L) { return Compact.FORMATTER.format2(value / Format.DOUBLE_KILO_BYTES) + " k"; } return "n/a"; }
/** * @param value * @return string */ public static final String toBytes(final long value) { if (value < 0) { return '-' + Format.Compact.toBytes(-value); } if (value < 1000L) { return String.valueOf(value) + ' '; } if (value >= 1000L * 1000L * 1000L * 1000L) { return Compact.FORMATTER.format2(value / Format.DOUBLE_TERA_BYTES) + " T"; } if (value >= 1000L * 1000L * 1000L) { return Compact.FORMATTER.format2(value / Format.DOUBLE_GIGA_BYTES) + " G"; } if (value >= 1000L * 1000L) { return Compact.FORMATTER.format2(value / Format.DOUBLE_MEGA_BYTES) + " M"; } return Compact.FORMATTER.format2(value / Format.DOUBLE_KILO_BYTES) + " k"; }