src/share/classes/java/lang/Float.java
Print this page
@@ -457,11 +457,11 @@
*
* @param v the value to be tested.
* @return {@code true} if the argument is NaN;
* {@code false} otherwise.
*/
- static public boolean isNaN(float v) {
+ public static boolean isNaN(float v) {
return (v != v);
}
/**
* Returns {@code true} if the specified number is infinitely
@@ -469,14 +469,29 @@
*
* @param v the value to be tested.
* @return {@code true} if the argument is positive infinity or
* negative infinity; {@code false} otherwise.
*/
- static public boolean isInfinite(float v) {
+ public static boolean isInfinite(float v) {
return (v == POSITIVE_INFINITY) || (v == NEGATIVE_INFINITY);
}
+
+ /**
+ * Returns {@code true} if the argument is a finite floating-point
+ * value; returns {@code false} otherwise (for NaN and infinity
+ * arguments).
+ *
+ * @param f the {@code float} value to be tested
+ * @return {@code true} if the argument is a finite
+ * floating-point value, {@code false} otherwise.
+ * @since 1.8
+ */
+ public static boolean isFinite(float f) {
+ return Math.abs(f) <= FloatConsts.MAX_VALUE;
+ }
+
/**
* The value of the Float.
*
* @serial
*/