compareTo method
Compares this BigRational with the given BigRational and returns an integer representing the result.
v
The BigRational to compare with.
Returns 0 if this BigRational is equal to the given BigRational, 1 if this BigRational is greater, and -1 if this BigRational is less.
Implementation
int compareTo(BigRational v) {
if (denominator == v.denominator) {
return numerator.compareTo(v.numerator);
}
final int comparison =
(denominator.isNegative == v.denominator.isNegative) ? 1 : -1;
return comparison *
(numerator * v.denominator).compareTo(v.numerator * denominator);
}