readBigInt method

BigInt readBigInt()

Implementation

BigInt readBigInt() {
  var bitField = reader.getVarint();
  var negative = (bitField & 1) != 0;
  bitField >>= 1;
  var bigInteger = BigInt.zero;
  for (var i = 0; i < bitField; i++) {
    var b = reader.getByte();
    for (var bit = 8 * i; bit < 8 * (i + 1); bit++) {
      if ((b & 1) != 0) {
        bigInteger = bigInteger.pow(bit);
      }
      b >>= 1;
    }
  }
  if (negative) {
    bigInteger = -bigInteger;
  }
  return bigInteger;
}