Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.2
-
None
-
None
Description
If two different fractions evaluate to the same double due to limited precision,
the compareTo methode returns 0 as if they were identical.
// 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