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:00:05 UTC
[14/37] commons-numbers git commit: NUMBERS-45: restored isNaN() and
isInfinite() methods
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/master
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);
}