Add mad corner case to unit tests to enforce maximum precision in doubleValue()
@@ -171,6 +171,7 @@ public class BigFractionTest {
@Test
public void testDoubleValue() {
+ {
BigFraction first = BigFraction.of(1, 2);
BigFraction second = BigFraction.of(1, 3);
@@ -178,6 +179,15 @@ public class BigFractionTest {
Assertions.assertEquals(1.0 / 3.0, second.doubleValue(), 0.0);
}
+ //NUMBERS-120
+ {
+ BigFraction f = BigFraction.of(
+ BigInteger.ONE.shiftLeft(54),
+ BigInteger.ONE.shiftLeft(53).add(BigInteger.ONE));
+ Assertions.assertEquals(2d - 0x1P-52, f.doubleValue());
+ }
+ }
+
@Test
public void testDoubleValueForSubnormalNumbers() {
{
