[ https://issues.apache.org/jira/browse/NUMBERS-147?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alex Herbert resolved NUMBERS-147. ---------------------------------- Fix Version/s: 1.0-beta1 Resolution: Fixed Conversion from a double has been revised to support a max denominator of 2^31. Conversion is performed on the absolute value and the sign restored at the end ensuring consistent conversion of +/- values. Add to master in commit: ae6a5e39b4e4c424959fbfdd9dc13aa05c3e3517 > Fraction/BigFraction from(double, int) should support Integer.MIN_VALUE as > max denominator > ------------------------------------------------------------------------------------------ > > Key: NUMBERS-147 > URL: https://issues.apache.org/jira/browse/NUMBERS-147 > Project: Commons Numbers > Issue Type: Bug > Components: fraction > Affects Versions: 1.0-beta1 > Reporter: Alex Herbert > Assignee: Alex Herbert > Priority: Minor > Fix For: 1.0-beta1 > > Time Spent: 0.5h > Remaining Estimate: 0h > > 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: > {code:java} > @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); > } > {code} > 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. -- This message was sent by Atlassian Jira (v8.3.4#803005)