106 */
107 public static final int MAX_EXPONENT = 1023;
108
109 /**
110 * Minimum exponent a normalized {@code double} variable may
111 * have. It is equal to the value returned by
112 * {@code Math.getExponent(Double.MIN_NORMAL)}.
113 *
114 * @since 1.6
115 */
116 public static final int MIN_EXPONENT = -1022;
117
118 /**
119 * The number of bits used to represent a {@code double} value.
120 *
121 * @since 1.5
122 */
123 public static final int SIZE = 64;
124
125 /**
126 * The {@code Class} instance representing the primitive type
127 * {@code double}.
128 *
129 * @since JDK1.1
130 */
131 public static final Class<Double> TYPE = (Class<Double>) Class.getPrimitiveClass("double");
132
133 /**
134 * Returns a string representation of the {@code double}
135 * argument. All characters mentioned below are ASCII characters.
136 * <ul>
137 * <li>If the argument is NaN, the result is the string
138 * "{@code NaN}".
139 * <li>Otherwise, the result is a string that represents the sign and
140 * magnitude (absolute value) of the argument. If the sign is negative,
141 * the first character of the result is '{@code -}'
142 * (<code>'\u002D'</code>); if the sign is positive, no sign character
143 * appears in the result. As for the magnitude <i>m</i>:
144 * <ul>
145 * <li>If <i>m</i> is infinity, it is represented by the characters
710 * result is the exclusive OR of the two halves of the
711 * {@code long} integer bit representation, exactly as
712 * produced by the method {@link #doubleToLongBits(double)}, of
713 * the primitive {@code double} value represented by this
714 * {@code Double} object. That is, the hash code is the value
715 * of the expression:
716 *
717 * <blockquote>
718 * {@code (int)(v^(v>>>32))}
719 * </blockquote>
720 *
721 * where {@code v} is defined by:
722 *
723 * <blockquote>
724 * {@code long v = Double.doubleToLongBits(this.doubleValue());}
725 * </blockquote>
726 *
727 * @return a {@code hash code} value for this object.
728 */
729 public int hashCode() {
730 long bits = doubleToLongBits(value);
731 return (int)(bits ^ (bits >>> 32));
732 }
733
734 /**
735 * Compares this object against the specified object. The result
736 * is {@code true} if and only if the argument is not
737 * {@code null} and is a {@code Double} object that
738 * represents a {@code double} that has the same value as the
739 * {@code double} represented by this object. For this
740 * purpose, two {@code double} values are considered to be
741 * the same if and only if the method {@link
742 * #doubleToLongBits(double)} returns the identical
743 * {@code long} value when applied to each.
744 *
745 * <p>Note that in most cases, for two instances of class
746 * {@code Double}, {@code d1} and {@code d2}, the
747 * value of {@code d1.equals(d2)} is {@code true} if and
748 * only if
749 *
|
106 */
107 public static final int MAX_EXPONENT = 1023;
108
109 /**
110 * Minimum exponent a normalized {@code double} variable may
111 * have. It is equal to the value returned by
112 * {@code Math.getExponent(Double.MIN_NORMAL)}.
113 *
114 * @since 1.6
115 */
116 public static final int MIN_EXPONENT = -1022;
117
118 /**
119 * The number of bits used to represent a {@code double} value.
120 *
121 * @since 1.5
122 */
123 public static final int SIZE = 64;
124
125 /**
126 * The number of bytes used to represent a {@code double} value.
127 *
128 * @since 1.8
129 */
130 public static final int BYTES = SIZE / Byte.SIZE;
131
132 /**
133 * The {@code Class} instance representing the primitive type
134 * {@code double}.
135 *
136 * @since JDK1.1
137 */
138 public static final Class<Double> TYPE = (Class<Double>) Class.getPrimitiveClass("double");
139
140 /**
141 * Returns a string representation of the {@code double}
142 * argument. All characters mentioned below are ASCII characters.
143 * <ul>
144 * <li>If the argument is NaN, the result is the string
145 * "{@code NaN}".
146 * <li>Otherwise, the result is a string that represents the sign and
147 * magnitude (absolute value) of the argument. If the sign is negative,
148 * the first character of the result is '{@code -}'
149 * (<code>'\u002D'</code>); if the sign is positive, no sign character
150 * appears in the result. As for the magnitude <i>m</i>:
151 * <ul>
152 * <li>If <i>m</i> is infinity, it is represented by the characters
717 * result is the exclusive OR of the two halves of the
718 * {@code long} integer bit representation, exactly as
719 * produced by the method {@link #doubleToLongBits(double)}, of
720 * the primitive {@code double} value represented by this
721 * {@code Double} object. That is, the hash code is the value
722 * of the expression:
723 *
724 * <blockquote>
725 * {@code (int)(v^(v>>>32))}
726 * </blockquote>
727 *
728 * where {@code v} is defined by:
729 *
730 * <blockquote>
731 * {@code long v = Double.doubleToLongBits(this.doubleValue());}
732 * </blockquote>
733 *
734 * @return a {@code hash code} value for this object.
735 */
736 public int hashCode() {
737 long bits = doubleToLongBits(value);
738 return (int)(bits ^ (bits >>> 32));
739 }
740
741 /**
742 * Returns a hash code for a {@code double} value; compatible with
743 * {@code Double.hashCode()}.
744 *
745 * @since 1.8
746 *
747 * @return a hash code value for a {@code double} value.
748 */
749 public static int hashCode(double value) {
750 long bits = doubleToLongBits(value);
751 return (int)(bits ^ (bits >>> 32));
752 }
753
754 /**
755 * Compares this object against the specified object. The result
756 * is {@code true} if and only if the argument is not
757 * {@code null} and is a {@code Double} object that
758 * represents a {@code double} that has the same value as the
759 * {@code double} represented by this object. For this
760 * purpose, two {@code double} values are considered to be
761 * the same if and only if the method {@link
762 * #doubleToLongBits(double)} returns the identical
763 * {@code long} value when applied to each.
764 *
765 * <p>Note that in most cases, for two instances of class
766 * {@code Double}, {@code d1} and {@code d2}, the
767 * value of {@code d1.equals(d2)} is {@code true} if and
768 * only if
769 *
|