A ByteUnit represents a scaling factor applied to some number of bytes.
Such scaling factors are intended to make it easier for humans to understand
large (and small) numbers and understand how two numbers compare; as such,
ByteUnit is often used with interfacing with humans.
There are two types of ByteUnit: ones that use decimal (base-10) prefixes and
ones that use binary (base-2) prefixes. Decimal prefixes represent scaling
factors of the form 10^3n, where n is some non-negative integer. Binary
prefixes represent scaling factors of the form 2^10n, where n is some
non-negative integer. ByteUnit.BYTES is considered both a decimal and
binary scaling factor (i.e., with n=0 in both cases).
To avoid potential ambiguity, the ByteUnit enum values use ISO symbols. It
contains both binary and decimal prefixes in strict ascending order.
Conversions are supported for int, long, float and double. For the two
integer types (int and long) the maximum value is taken as a special case:
any conversion is always the same MAX_VALUE. For integer numbers less than
the maximum value, the conversion could overflow (be less than MIN_VALUE or
more than MAX_VALUE). If a conversion would overflow then an
ArithmeticException is thrown.
The maximum int and long values (Integer.MAX_VALUE and Long.MAX_VALUE
respectively) are accepted as a special case: any conversion will return the
same value.