readBigInt method

BigInt readBigInt()

Reads a BigInt. See BigIntExtension.toBytes for encoding description.

Implementation

BigInt readBigInt() {
  bytesIO.checkCanRead(5);

  try {
    final pos0 = bytesIO.position;

    final b0 = readByte();
    if (b0 == 0) {
      var n = readInt32();
      var bigInt = BigInt.from(n);
      return bigInt;
    } else {
      seek(pos0);
      var sz = -readInt32();
      var bs = readBytes(sz);
      var s = latin1.decode(bs);
      var bigInt = BigInt.parse(s);
      return bigInt;
    }
  } catch (_) {
    throw BytesBufferEOF();
  }
}