commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aherb...@apache.org
Subject [commons-numbers] 07/07: Pre-compute bit representation of -0.0.
Date Sun, 29 Dec 2019 22:06:04 GMT
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 fd3e2f1e8c0d2955556164d9223aa463e99af9da
Author: Alex Herbert <aherbert@apache.org>
AuthorDate: Sun Dec 29 21:58:52 2019 +0000

    Pre-compute bit representation of -0.0.
---
 .../src/main/java/org/apache/commons/numbers/complex/Complex.java     | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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 e7c247f..967a196 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
@@ -85,6 +85,8 @@ public final class Complex implements Serializable  {
     private static final double ROOT2 = Math.sqrt(2);
     /** The number of bits of precision of the mantissa of a {@code double} + 1: {@code 54}.
*/
     private static final double PRECISION_1 = 54;
+    /** The bit representation of {@code -0.0}. */
+    private static final long NEGATIVE_ZERO_LONG_BITS = Double.doubleToLongBits(-0.0);
 
     /**
      * Crossover point to switch computation for asin/acos factor A.
@@ -2544,7 +2546,7 @@ public final class Complex implements Serializable  {
      * @return {@code true} if {@code d} is negative.
      */
     private static boolean negative(double d) {
-        return d < 0 || equals(d, -0.0);
+        return d < 0 || Double.doubleToLongBits(d) == NEGATIVE_ZERO_LONG_BITS;
     }
 
     /**


Mime
View raw message