operator ~/ method
Truncating division operator.
Performs truncating division of this number by other
.
Truncating division is division where a fractional result
is converted to an integer by rounding towards zero.
If both operands are ints, then other
must not be zero.
Then a ~/ b
corresponds to a.remainder(b)
such that a == (a ~/ b) * b + a.remainder(b)
.
a ~/ b
is equivalent to (a / b).truncate()
.
This means that the intermediate result of the double division
must be a finite integer (not an infinity or double.nan).
Returns i4
Implementation
@override
i4 operator ~/(dynamic other) {
if (other is integer) {
return i4(value ~/ other.value);
} else if (other is int) {
return i4(value ~/ other);
} else if (other is double) {
return i4(value ~/ other);
} else {
throw Exception('Invalid type for operand: ${other.runtimeType}');
}
}