This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit 5d289a73786ab4ca10bdbd251bacad62c3f5c52b
Author: Alex Herbert <[email protected]>
AuthorDate: Wed Nov 6 21:56:22 2019 +0000

    Use Double.hashCode from JDK 1.8.
    
    The JDK implementation matches the removed private method hash(double)
    that probably was a backport from Java 8.
---
 .../java/org/apache/commons/numbers/complex/Complex.java     | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git 
a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
 
b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
index aa23ed5..238abf2 100644
--- 
a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
+++ 
b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
@@ -525,17 +525,7 @@ public final class Complex implements Serializable  {
             Double.isNaN(imaginary)) {
             return 7;
         }
-        return 37 * (17 * hash(imaginary) + hash(real));
-    }
-
-    /**
-     * @param d Value.
-     * @return a hash code for the given value.
-     */
-    private int hash(double d) {
-        final long v = Double.doubleToLongBits(d);
-        return (int) (v ^ (v >>> 32));
-        //return new Double(d).hashCode();
+        return 37 * (17 * Double.hashCode(imaginary) + Double.hashCode(real));
     }
 
     /**

Reply via email to