Int64.fromBytes constructor

Int64.fromBytes(
  1. List<int> bytes
)

Implementation

factory Int64.fromBytes(List<int> bytes) {
  // 20 bits into top, 22 into middle and bottom.
  var split1 = bytes[5] & 0xFF;
  var high =
      ((bytes[7] & 0xFF) << 12) | ((bytes[6] & 0xFF) << 4) | (split1 >> 4);
  var split2 = bytes[2] & 0xFF;
  var middle = (split1 << 18) |
      ((bytes[4] & 0xFF) << 10) |
      ((bytes[3] & 0xFF) << 2) |
      (split2 >> 6);
  var low = (split2 << 16) | ((bytes[1] & 0xFF) << 8) | (bytes[0] & 0xFF);
  // Top bits from above will be masked off here.
  return Int64._masked(low, middle, high);
}