bitlengthInBytes static method
Implementation
static int bitlengthInBytes(int value, {bool sign = false}) {
if (value < 0 && !sign) {
throw ArgumentException.invalidOperationArguments(
'bitlengthInBytesInt',
name: 'value',
reason: 'Negative value requires sign: true.',
);
}
int bits = value.bitLength;
if (sign) bits += 1;
if (bits == 0) return 1;
return (bits + 7) ~/ 8;
}