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 2017/07/05 12:25:56 UTC

commons-numbers git commit: NUMBERS-45: restored isNaN() and isInfinite() methods

Repository: commons-numbers
Updated Branches:
  refs/heads/complex-dev 3bd29a023 -> f1a8f9071


NUMBERS-45: restored isNaN() and isInfinite() methods


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

Branch: refs/heads/complex-dev
Commit: f1a8f907145d343c2ea161d76c32b05740c43742
Parents: 3bd29a0
Author: Eric Barnhill <er...@apache.org>
Authored: Wed Jul 5 14:27:27 2017 +0200
Committer: Eric Barnhill <er...@apache.org>
Committed: Wed Jul 5 14:27:27 2017 +0200

----------------------------------------------------------------------
 .../apache/commons/numbers/complex/Complex.java | 31 ++++++++++++++++++--
 1 file changed, 28 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/f1a8f907/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 5e54578..adc03b1 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
@@ -127,6 +127,34 @@ public class Complex implements Serializable  {
     }
 
     /**
+     * Returns true if either real or imaginary component of the Complex
+     * is NaN
+     * 
+     * @return {@code boolean}
+     */
+    public boolean isNaN() {
+        if (Double.isNaN(real) || Double.isNaN(imaginary)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Returns true if either real or imaginary component of the Complex
+     * is Infinite 
+     * 
+     * @return {@code boolean}
+     */
+    public boolean isInfinite() {
+        if (Double.isInfinite(real) || Double.isInfinite(imaginary)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
      * Returns projection of this complex number onto the Riemann sphere,
      * i.e. all infinities (including those with an NaN component)
      * project onto real infinity, as described in the
@@ -1104,9 +1132,6 @@ in the
      * @return a Complex instance.
      */
     public static Complex valueOf(double realPart) {
-        if (Double.isNaN(realPart)) {
-            return NaN;
-        }
         return new Complex(realPart);
     }