bitlengthInBytes static method
Calculates the number of bytes required to represent the bit length of an integer value.
Implementation
static int bitlengthInBytes(int val) {
int bitlength = val.bitLength;
if (bitlength == 0) return 1;
if (val.isNegative) {
bitlength += 1;
}
return (bitlength + 7) ~/ 8;
}