decodeSigned static method
Decodes a LEB128 bytes
of a signed integer.
n
(optional) argument specifies the number of bits in the integer.
Implementation
static int decodeSigned(List<int> bytes, {int n = 64}) {
var result = 0;
var shift = 0;
var i = 0;
while (true) {
var byte = bytes[i];
result |= _platform.shiftLeftInt((byte & 0x7F), shift);
shift += 7;
if ((byte & 0x80) == 0) {
break;
}
++i;
}
if ((shift < n) && (bytes[i] & 0x40) != 0) {
if (_platform.supportsFullBitsShift) {
result |= _platform.shiftLeftInt(-1, shift);
} else {
result = (BigInt.from(result) | (BigInt.from(-1) << shift)).toInt();
}
}
return result;
}