src/share/classes/java/lang/Double.java

Print this page
rev 6151 : imported patch reducers

@@ -1019,8 +1019,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 double} values together as per the + operator.
+     * Suitable for conversion as a method reference to functional interfaces such
+     * as {@code BinaryOperator&lt;Double&gt;} or {@code DoubleBinaryOperator}.
+     *
+     * @param   a   an argument.
+     * @param   b   another argument.
+     * @return  the sum of {@code a} and {@code b}.
+     * @since 1.8
+     */
+    public static double sum(double a, double b) {
+        return a + b;
+    }
+
+    /**
+     * Returns the greater of two {@code double} values.
+     * Suitable for conversion as a method reference to functional interfaces such
+     * as {@code BinaryOperator&lt;Double&gt;} or {@code DoubleBinaryOperator}.
+     *
+     * @param   a   an argument.
+     * @param   b   another argument.
+     * @return  the larger of {@code a} and {@code b}.
+     * @since 1.8
+     */
+    public static double max(double a, double b) {
+        return (a >= b) ? a : b;
+    }
+
+    /**
+     * Returns the lesser of two {@code double} values.
+     * Suitable for conversion as a method reference to functional interfaces such
+     * as {@code BinaryOperator&lt;Double&gt;} or {@code DoubleBinaryOperator}.
+     *
+     * @param   a   an argument.
+     * @param   b   another argument.
+     * @return  the lesser of {@code a} and {@code b}.
+     * @since 1.8
+     */
+    public static double min(double a, double b) {
+        return (a <= b) ? a : b;
+    }
+
     /** use serialVersionUID from JDK 1.0.2 for interoperability */
     private static final long serialVersionUID = -9172774392245257468L;
 }