decodeSigned static method

BigInt decodeSigned(
  1. List<int> bytes
)

De-Serializes a leb128 signed format into a BigInt

Implementation

static BigInt decodeSigned(List<int> bytes) {
    String bitstring = '';
    int first_byte = bytes[bytes.length-1];
    bitstring = first_byte.toRadixString(2);
    for (int byte in bytes.reversed.toList().sublist(1)) {
        String bitstring_7_part = byte.toRadixString(2).substring(1);
        bitstring = bitstring + bitstring_7_part;
    }
    return twos_compliment_bitstring_as_the_bigint(bitstring, bit_size: bytes.length*7);
}