MATH-1617: Ensure that "hashCode" is consistent with "equals".

This commit is contained in:
Ng Tsz Sum 2021-07-19 22:12:45 +08:00 committed by Gilles Sadowski
parent 8cd59b991e
commit 30a2593c2c
2 changed files with 2 additions and 1 deletions

View File

@ -323,7 +323,7 @@ public class BigReal implements FieldElement<BigReal>, Comparable<BigReal>, Seri
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public int hashCode() { public int hashCode() {
return d.hashCode(); return Double.hashCode(d.doubleValue());
} }
/** {@inheritDoc} */ /** {@inheritDoc} */

View File

@ -178,6 +178,7 @@ public class BigRealTest {
BigReal oneWithScaleOne = new BigReal(new BigDecimal("1.0")); BigReal oneWithScaleOne = new BigReal(new BigDecimal("1.0"));
BigReal oneWithScaleTwo = new BigReal(new BigDecimal("1.00")); BigReal oneWithScaleTwo = new BigReal(new BigDecimal("1.00"));
Assert.assertEquals(oneWithScaleOne, oneWithScaleTwo); Assert.assertEquals(oneWithScaleOne, oneWithScaleTwo);
Assert.assertEquals(oneWithScaleOne.hashCode(), oneWithScaleTwo.hashCode());
} }
@Test @Test