File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed
src/java.base/share/classes/java/lang Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -1242,6 +1242,8 @@ public static int hashCode(double value) {
12421242 * the same if and only if the method {@link
12431243 * #doubleToLongBits(double)} returns the identical
12441244 * {@code long} value when applied to each.
1245+ * In other words, {@linkplain ##repEquivalence representation
1246+ * equivalence} is used to compare the {@code double} values.
12451247 *
12461248 * @apiNote
12471249 * This method is defined in terms of {@link
@@ -1455,6 +1457,12 @@ public int compareTo(Double anotherDouble) {
14551457 * Double.valueOf(d1).compareTo(Double.valueOf(d2))
14561458 * </pre>
14571459 *
1460+ * @apiNote
1461+ * One idiom to implement {@linkplain ##repEquivalence
1462+ * representation equivalence} on {@code double} values is
1463+ * {@snippet lang="java" :
1464+ * Double.compare(a, b) == 0
1465+ * }
14581466 * @param d1 the first {@code double} to compare
14591467 * @param d2 the second {@code double} to compare
14601468 * @return the value {@code 0} if {@code d1} is
Original file line number Diff line number Diff line change @@ -871,6 +871,9 @@ public static int hashCode(float value) {
871871 * same if and only if the method {@link #floatToIntBits(float)}
872872 * returns the identical {@code int} value when applied to
873873 * each.
874+ * In other words, {@linkplain Double##repEquivalence
875+ * representation equivalence} is used to compare the {@code
876+ * float} values.
874877 *
875878 * @apiNote
876879 * This method is defined in terms of {@link
@@ -1276,6 +1279,14 @@ public int compareTo(Float anotherFloat) {
12761279 * Float.valueOf(f1).compareTo(Float.valueOf(f2))
12771280 * </pre>
12781281 *
1282+ * @apiNote
1283+ * One idiom to implement {@linkplain
1284+ * Double##repEquivalence representation equivalence} on {@code
1285+ * float} values is
1286+ * {@snippet lang="java" :
1287+ * Float.compare(a, b) == 0
1288+ * }
1289+ *
12791290 * @param f1 the first {@code float} to compare.
12801291 * @param f2 the second {@code float} to compare.
12811292 * @return the value {@code 0} if {@code f1} is
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2019, 2024 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2019, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -127,7 +127,12 @@ protected Record() {}
127127 *
128128 * </ul>
129129 *
130- * Apart from the semantics described above, the precise algorithm
130+ * Note that these rules imply that {@linkplain
131+ * Double##repEquivalence representation equivalence} is used for
132+ * the equality comparison of both primitive floating-point values
133+ * and wrapped floating-point values.
134+ *
135+ * <p>Apart from the semantics described above, the precise algorithm
131136 * used in the implicitly provided implementation is unspecified
132137 * and is subject to change. The implementation may or may not use
133138 * calls to the particular methods listed, and may or may not
You can’t perform that action at this time.
0 commit comments