bitsToBigInt static method

BigInt bitsToBigInt(
  1. List<bool> bits, {
  2. Endian endian = Endian.little,
})

Implementation

static BigInt bitsToBigInt(List<bool> bits, {Endian endian = Endian.little}) {
  BigInt value = BigInt.zero;
  int n = bits.length;
  if (endian == Endian.little) {
    for (int i = 0; i < n; i++) {
      if (bits[i]) {
        value |= (BigInt.one << i);
      }
    }
  } else {
    for (int i = 0; i < n; i++) {
      if (bits[i]) {
        value |= (BigInt.one << (n - 1 - i));
      }
    }
  }
  return value;
}