Richard Mullender created NUMBERS-207: -----------------------------------------
Summary: Fraction and BigFraction compareTo incorrect for negative values Key: NUMBERS-207 URL: https://issues.apache.org/jira/browse/NUMBERS-207 Project: Commons Numbers Issue Type: Bug Components: fraction Affects Versions: 1.2 Reporter: Richard Mullender Both `Fraction` and `BigFraction` display incorrect `compareTo` behaviour when comparing negative fractions against one another. See the below test class: {code:java} public class FractionTest { @Test public void testFraction() { var fraction1 = org.apache.commons.numbers.fraction.Fraction.of(-10, 1); var fraction2 = org.apache.commons.numbers.fraction.Fraction.of(-5, 1); assert fraction1.compareTo(fraction2) < 0; } @Test public void testBigFraction() { var fraction1 = org.apache.commons.numbers.fraction.BigFraction.of(-10, 1); var fraction2 = org.apache.commons.numbers.fraction.BigFraction.of(-5, 1); assert fraction1.compareTo(fraction2) < 0; } @Test public void testApacheLang3() { var fraction1 = org.apache.commons.lang3.math.Fraction.getFraction(-10, 1); var fraction2 = org.apache.commons.lang3.math.Fraction.getFraction(-5, 1); assert fraction1.compareTo(fraction2) < 0; } } {code} Out of these three tests, only Lang3's Fraction passes. The other two tests (fraction.Fraction and fraction.BigFraction) fail. -- This message was sent by Atlassian Jira (v8.20.10#820010)