You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2021/07/19 16:03:54 UTC
[commons-math] branch master updated: MATH-1617: Ensure that
"hashCode" is consistent with "equals".
This is an automated email from the ASF dual-hosted git repository.
erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git
The following commit(s) were added to refs/heads/master by this push:
new 30a2593 MATH-1617: Ensure that "hashCode" is consistent with "equals".
30a2593 is described below
commit 30a2593c2c9808d7ad118d8e120e8ce807df746a
Author: Ng Tsz Sum <ts...@gmail.com>
AuthorDate: Mon Jul 19 22:12:45 2021 +0800
MATH-1617: Ensure that "hashCode" is consistent with "equals".
---
.../src/main/java/org/apache/commons/math4/legacy/linear/BigReal.java | 2 +-
.../test/java/org/apache/commons/math4/legacy/linear/BigRealTest.java | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/linear/BigReal.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/linear/BigReal.java
index 744fe1b..6450e56 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/linear/BigReal.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/linear/BigReal.java
@@ -323,7 +323,7 @@ public class BigReal implements FieldElement<BigReal>, Comparable<BigReal>, Seri
/** {@inheritDoc} */
@Override
public int hashCode() {
- return d.hashCode();
+ return Double.hashCode(d.doubleValue());
}
/** {@inheritDoc} */
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BigRealTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BigRealTest.java
index 9c25404..f02741b 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BigRealTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BigRealTest.java
@@ -178,6 +178,7 @@ public class BigRealTest {
BigReal oneWithScaleOne = new BigReal(new BigDecimal("1.0"));
BigReal oneWithScaleTwo = new BigReal(new BigDecimal("1.00"));
Assert.assertEquals(oneWithScaleOne, oneWithScaleTwo);
+ Assert.assertEquals(oneWithScaleOne.hashCode(), oneWithScaleTwo.hashCode());
}
@Test