compareTo method
Compare two Decimals
NOTES:
- This comparison ignores trailing zeros. If you need strict equality (including scale), use strictEquals method.
- If other is a Rational, it will be converted to Rational for comparison.
Implementation
@override
int compareTo(Decimal other) {
if (other is Rational) {
return this.toRational().compareTo(other);
}
final maxScale = math.max(_scale, other._scale);
final thisValue = _value * pow10(maxScale - _scale);
final otherValue = other._value * pow10(maxScale - other._scale);
return thisValue.compareTo(otherValue);
}