```
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.lang;
27
28 import jdk.internal.math.FloatingDecimal;
29 import jdk.internal.math.DoubleConsts;
30 import jdk.internal.HotSpotIntrinsicCandidate;
31
32 /**
33 * The {@code Double} class wraps a value of the primitive type
34 * {@code double} in an object. An object of type
35 * {@code Double} contains a single field whose type is
36 * {@code double}.
37 *
38 * <p>In addition, this class provides several methods for converting a
39 * {@code double} to a {@code String} and a
40 * {@code String} to a {@code double}, as well as other
41 * constants and methods useful when dealing with a
42 * {@code double}.
43 *
44 * @author Lee Boynton
45 * @author Arthur van Hoff
46 * @author Joseph D. Darcy
47 * @since 1.0
48 */
49 public final class Double extends Number implements Comparable<Double> {
50 /**
51 * A constant holding the positive infinity of type
52 * {@code double}. It is equal to the value returned by
53 * {@code Double.longBitsToDouble(0x7ff0000000000000L)}.
54 */
55 public static final double POSITIVE_INFINITY = 1.0 / 0.0;
56
57 /**
58 * A constant holding the negative infinity of type
59 * {@code double}. It is equal to the value returned by
60 * {@code Double.longBitsToDouble(0xfff0000000000000L)}.
61 */
62 public static final double NEGATIVE_INFINITY = -1.0 / 0.0;
63
64 /**
65 * A constant holding a Not-a-Number (NaN) value of type
66 * {@code double}. It is equivalent to the value returned by
67 * {@code Double.longBitsToDouble(0x7ff8000000000000L)}.
68 */
69 public static final double NaN = 0.0d / 0.0;
``` 1047 * @return the greater of {@code a} and {@code b} 1048 * @see java.util.function.BinaryOperator 1049 * @since 1.8 1050 */ 1051 public static double max(double a, double b) { 1052 return Math.max(a, b); 1053 } 1054 1055 /** 1056 * Returns the smaller of two {@code double} values 1057 * as if by calling {@link Math#min(double, double) Math.min}. 1058 * 1059 * @param a the first operand 1060 * @param b the second operand 1061 * @return the smaller of {@code a} and {@code b}. 1062 * @see java.util.function.BinaryOperator 1063 * @since 1.8 1064 */ 1065 public static double min(double a, double b) { 1066 return Math.min(a, b); 1067 } 1068 1069 /** use serialVersionUID from JDK 1.0.2 for interoperability */ 1070 private static final long serialVersionUID = -9172774392245257468L; 1071 } | 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.lang; 27 28 import java.lang.invoke.Constable; 29 import java.lang.invoke.MethodHandles; 30 31 import jdk.internal.math.FloatingDecimal; 32 import jdk.internal.math.DoubleConsts; 33 import jdk.internal.HotSpotIntrinsicCandidate; 34 35 /** 36 * The {@code Double} class wraps a value of the primitive type 37 * {@code double} in an object. An object of type 38 * {@code Double} contains a single field whose type is 39 * {@code double}. 40 * 41 * <p>In addition, this class provides several methods for converting a 42 * {@code double} to a {@code String} and a 43 * {@code String} to a {@code double}, as well as other 44 * constants and methods useful when dealing with a 45 * {@code double}. 46 * 47 * @author Lee Boynton 48 * @author Arthur van Hoff 49 * @author Joseph D. Darcy 50 * @since 1.0 51 */ 52 public final class Double extends Number implements Comparable<Double>, Constable<Double> { 53 /** 54 * A constant holding the positive infinity of type 55 * {@code double}. It is equal to the value returned by 56 * {@code Double.longBitsToDouble(0x7ff0000000000000L)}. 57 */ 58 public static final double POSITIVE_INFINITY = 1.0 / 0.0; 59 60 /** 61 * A constant holding the negative infinity of type 62 * {@code double}. It is equal to the value returned by 63 * {@code Double.longBitsToDouble(0xfff0000000000000L)}. 64 */ 65 public static final double NEGATIVE_INFINITY = -1.0 / 0.0; 66 67 /** 68 * A constant holding a Not-a-Number (NaN) value of type 69 * {@code double}. It is equivalent to the value returned by 70 * {@code Double.longBitsToDouble(0x7ff8000000000000L)}. 71 */ 72 public static final double NaN = 0.0d / 0.0; 1050 * @return the greater of {@code a} and {@code b} 1051 * @see java.util.function.BinaryOperator 1052 * @since 1.8 1053 */ 1054 public static double max(double a, double b) { 1055 return Math.max(a, b); 1056 } 1057 1058 /** 1059 * Returns the smaller of two {@code double} values 1060 * as if by calling {@link Math#min(double, double) Math.min}. 1061 * 1062 * @param a the first operand 1063 * @param b the second operand 1064 * @return the smaller of {@code a} and {@code b}. 1065 * @see java.util.function.BinaryOperator 1066 * @since 1.8 1067 */ 1068 public static double min(double a, double b) { 1069 return Math.min(a, b); 1070 } 1071 1072 @Override 1073 public Double resolveConstant(MethodHandles.Lookup lookup) { 1074 return this; 1075 } 1076 1077 /** use serialVersionUID from JDK 1.0.2 for interoperability */ 1078 private static final long serialVersionUID = -9172774392245257468L; 1079 } |