[
https://issues.apache.org/jira/browse/NUMBERS-207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17935784#comment-17935784
]
Richard Mullender commented on NUMBERS-207:
-------------------------------------------
Ah, that makes a lot of sense, thanks for the additional context.
No, comparisons aren't a bottleneck for me, so the additional complexity isn't
an issue, I was just curious of the reasoning behind it.
Thank you again for the quick responses and turnaround on this issue!
> 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
> Priority: Major
>
> 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)