src/share/classes/java/lang/Float.java

Print this page
rev 6151 : imported patch reducers

@@ -924,8 +924,50 @@
         return (thisBits == anotherBits ?  0 : // Values are equal
                 (thisBits < anotherBits ? -1 : // (-0.0, 0.0) or (!NaN, NaN)
                  1));                          // (0.0, -0.0) or (NaN, !NaN)
     }
 
+    /**
+     * Adds two {@code float} values together as per the + operator.
+     * Suitable for conversion as a method reference to functional interfaces such
+     * as {@code BinaryOperator&lt;Float&gt;}.
+     *
+     * @param   a   an argument.
+     * @param   b   another argument.
+     * @return  the sum of {@code a} and {@code b}.
+     * @since 1.8
+     */
+    public static float sum(float a, float b) {
+        return a + b;
+    }
+
+    /**
+     * Returns the greater of two {@code float} values.
+     * Suitable for conversion as a method reference to functional interfaces such
+     * as {@code BinaryOperator&lt;Float&gt;}.
+     *
+     * @param   a   an argument.
+     * @param   b   another argument.
+     * @return  the larger of {@code a} and {@code b}.
+     * @since 1.8
+     */
+    public static float max(float a, float b) {
+        return (a >= b) ? a : b;
+    }
+
+    /**
+     * Returns the lesser of two {@code float} values.
+     * Suitable for conversion as a method reference to functional interfaces such
+     * as {@code BinaryOperator&lt;Float&gt;}.
+     *
+     * @param   a   an argument.
+     * @param   b   another argument.
+     * @return  the lesser of {@code a} and {@code b}.
+     * @since 1.8
+     */
+    public static float min(float a, float b) {
+        return (a <= b) ? a : b;
+    }
+
     /** use serialVersionUID from JDK 1.0.2 for interoperability */
     private static final long serialVersionUID = -2671257302660747028L;
 }