fromBytes static method
Implementation
static BigInt fromBytes(
{required List<int> bytes,
required int offset,
required int end,
Endian byteOrder = Endian.big,
bool sign = false}) {
BigInt result = BigInt.zero;
if (byteOrder == Endian.little) {
int j = 0;
for (int i = offset; i < end; i++) {
/// Add each byte to the result, considering its position and byte order.
result += BigInt.from(bytes[i]) << (8 * j++);
}
if (result == BigInt.zero) return result;
if (sign && (bytes[end - 1] & 0x80) != 0) {
return result.toSigned(BigintUtils.bitlengthInBytes(result) * 8);
}
} else {
int j = 0;
for (int i = offset; i < end; i++) {
result += BigInt.from(bytes[end - 1 - j]) << (8 * j++);
}
if (result == BigInt.zero) return result;
if (sign && (bytes[offset] & 0x80) != 0) {
return result.toSigned(BigintUtils.bitlengthInBytes(result) * 8);
}
}
return result;
}