summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2015-02-26 21:27:34 +1100
committermd_5 <git@md-5.net>2015-02-26 21:27:34 +1100
commit2b22e68f5a98e69f0ab92f7e8ad6653e8ecc0599 (patch)
tree24a9815c727dbce8e7b157491467bec0d18b1914
parentfb96a1afa922ee61b6a66420f640d6fef9771145 (diff)
downloadbukkit-2b22e68f5a98e69f0ab92f7e8ad6653e8ecc0599.tar
bukkit-2b22e68f5a98e69f0ab92f7e8ad6653e8ecc0599.tar.gz
bukkit-2b22e68f5a98e69f0ab92f7e8ad6653e8ecc0599.tar.lz
bukkit-2b22e68f5a98e69f0ab92f7e8ad6653e8ecc0599.tar.xz
bukkit-2b22e68f5a98e69f0ab92f7e8ad6653e8ecc0599.zip
Add isFinite util methods.
-rw-r--r--src/main/java/org/bukkit/util/NumberConversions.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/util/NumberConversions.java b/src/main/java/org/bukkit/util/NumberConversions.java
index 4bc79028..e6af9ec7 100644
--- a/src/main/java/org/bukkit/util/NumberConversions.java
+++ b/src/main/java/org/bukkit/util/NumberConversions.java
@@ -102,14 +102,22 @@ public final class NumberConversions {
return 0;
}
+ public static boolean isFinite(double d) {
+ return Math.abs(d) <= Double.MAX_VALUE;
+ }
+
+ public static boolean isFinite(float f) {
+ return Math.abs(f) <= Float.MAX_VALUE;
+ }
+
public static void checkFinite(double d, String message) {
- if (Double.isNaN(d) || Double.isInfinite(d)) {
+ if (!isFinite(d)) {
throw new IllegalArgumentException(message);
}
}
public static void checkFinite(float d, String message) {
- if (Float.isNaN(d) || Float.isInfinite(d)) {
+ if (!isFinite(d)) {
throw new IllegalArgumentException(message);
}
}