Fraction.comparTo returns 0 for some differente fractions
---------------------------------------------------------
Key: MATH-252
URL: https://issues.apache.org/jira/browse/MATH-252
Project: Commons Math
Issue Type: Bug
Affects Versions: 1.2
Reporter: Luc Maisonobe
Assignee: Luc Maisonobe
Fix For: 2.0
If two different fractions evaluate to the same double due to limited precision,
the compareTo methode returns 0 as if they were identical.
{code}
// value is roughly PI - 3.07e-18
Fraction pi1 = new Fraction(1068966896, 340262731);
// value is roughly PI + 1.936e-17
Fraction pi2 = new Fraction( 411557987, 131002976);
System.out.println(pi1.doubleValue() - pi2.doubleValue()); // exactly 0.0 due
to limited IEEE754 precision
System.out.println(pi1.compareTo(pi2)); // display 0 instead of a negative value
{code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.