operator ~/ method
Integer division using decimal-safe operands.
Implementation
int operator ~/(Object other) {
final right = _coerceOperand(other, operation: '~/');
if (right.scaledValue == BigInt.zero) {
throw UnsupportedError('Division by zero');
}
final commonScale = scale > right.scale ? scale : right.scale;
final leftScaled = _rescaleExact(
scaledValue,
fromScale: scale,
toScale: commonScale,
);
final rightScaled = _rescaleExact(
right.scaledValue,
fromScale: right.scale,
toScale: commonScale,
);
return (leftScaled ~/ rightScaled).toInt();
}