toInt method

int toInt()

Safe only if the magnitude fits in 53 bits — delegates to Uint64.toInt()'s own guard, so it throws IntegerError otherwise.

Implementation

int toInt() {
  final negative = isNegative;
  final magnitudeBits = negative ? ((~_bits) + Uint64.one) : _bits;
  final mag =
      magnitudeBits.toInt(); // throws if too large for a double-safe int
  return negative ? -mag : mag;
}