Description
Fraction allows the use of Integer.MIN_VALUE for the denominator. The conversion from a double using a maximum denominator only supports values up to Integer.MAX_VALUE. This is a legacy from when Fraction was limited to Integer.MAX_VALUE in the denominator.
Currently this test fails:
@Test public void testFromDoubleUsingMaxDenominator() { Fraction f1 = Fraction.of(-1, Integer.MIN_VALUE); Fraction f2 = Fraction.from(f1.doubleValue(), Integer.MIN_VALUE); Assertions.assertEquals(f1, f2); }
It should be possible to round-trip the most extreme small value that can be stored in a fraction to a double and then back again.
The method requires updating to set the overflow limit (which is a long) as 2^31 and not 2^31-1.
The same method is used in BigFraction.from which should also be updated.
Attachments
Issue Links
- links to