toInt method

int toInt()

Safe only if the magnitude fits in a double-safe int — delegates to Uint128.toInt()'s own guard, so it throws IntegerError otherwise (use toBigInt for the general case).

Implementation

int toInt() {
  final negative = isNegative;
  final magnitudeBits = negative ? ((~_bits) + Uint128.one) : _bits;
  final mag = magnitudeBits.toInt();
  return negative ? -mag : mag;
}