src/share/classes/java/lang/Double.java
Print this page
rev 4568 : 7088952: Add "BYTES" constant to primitive wrapper classes
7088913: Add compatible static hashCode(primitive) to primitive wrapper classes
Reviewed-by: smarks
*** 121,130 ****
--- 121,137 ----
* @since 1.5
*/
public static final int SIZE = 64;
/**
+ * The number of bytes used to represent a {@code double} value.
+ *
+ * @since 1.8
+ */
+ public static final int BYTES = SIZE / Byte.SIZE;
+
+ /**
* The {@code Class} instance representing the primitive type
* {@code double}.
*
* @since JDK1.1
*/
*** 730,739 ****
--- 737,759 ----
long bits = doubleToLongBits(value);
return (int)(bits ^ (bits >>> 32));
}
/**
+ * Returns a hash code for a {@code double} value; compatible with
+ * {@code Double.hashCode()}.
+ *
+ * @since 1.8
+ *
+ * @return a hash code value for a {@code double} value.
+ */
+ public static int hashCode(double value) {
+ long bits = doubleToLongBits(value);
+ return (int)(bits ^ (bits >>> 32));
+ }
+
+ /**
* Compares this object against the specified object. The result
* is {@code true} if and only if the argument is not
* {@code null} and is a {@code Double} object that
* represents a {@code double} that has the same value as the
* {@code double} represented by this object. For this