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 2018/01/26 14:44:51 UTC

[31/36] commons-numbers git commit: NUMBERS-22: fixed bitwise OR and set double values in reciprocal() to final

NUMBERS-22: fixed bitwise OR and set double values in reciprocal() to final


Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/463f0179
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/463f0179
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/463f0179

Branch: refs/heads/master
Commit: 463f0179910b91216e28e04e0bbe279269209d86
Parents: f0d1b9c
Author: Eric Barnhill <er...@apache.org>
Authored: Thu Sep 7 15:46:54 2017 +0200
Committer: Eric Barnhill <er...@apache.org>
Committed: Thu Sep 7 15:46:54 2017 +0200

----------------------------------------------------------------------
 .../apache/commons/numbers/complex/Complex.java | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/463f0179/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
----------------------------------------------------------------------
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 d396619..e771bca 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
@@ -353,22 +353,18 @@ in the
      */
     public Complex reciprocal() {
         if (Math.abs(real) < Math.abs(imaginary)) {
-            double q = real / imaginary;
-            double scale = 1. / (real * q + imaginary);
-            double scaleQ;
-            if (q == 0 | scale == 0) {
-                scaleQ = 0;
-            } else {
+            final double q = real / imaginary;
+            final double scale = 1. / (real * q + imaginary);
+            final double scaleQ;
+            if (q != 0 && scale != 0) {
                 scaleQ = scale * q;
             }
             return new Complex(scaleQ, -scale);
         } else {
-            double q = imaginary / real;
-            double scale = 1. / (imaginary * q + real);
-            double scaleQ;
-            if (q == 0 | scale == 0) {
-                scaleQ = 0;
-            } else {
+            final double q = imaginary / real;
+            final double scale = 1. / (imaginary * q + real);
+            final double scaleQ;
+            if (q != 0 && scale != 0) {
                 scaleQ = scale * q;
             }
             return new Complex(scale, -scaleQ);