bigIntToBytesSigned static method

List<int> bigIntToBytesSigned(
  1. BigInt b,
  2. int numBytes
)

Implementation

static List<int> bigIntToBytesSigned(BigInt b, int numBytes) {
  var bytes = List<int>.filled(numBytes, b.sign < 0 ? 0xFF : 0x00, growable: true);
  var biBytes = encodeBigInt(b);
  var start = (biBytes.length == numBytes + 1) ? 1 : 0;
  var length = min(biBytes.length, numBytes);
  BytesUtils.arraycopy(biBytes, start, bytes, numBytes - length, length);
  return bytes;
}