📄 javalang.doc9.html
字号:
<html>
<head>
<title>The Java Language Specification The Package java.lang </title>
</head>
<body BGCOLOR=#eeeeff text=#000000 LINK=#0000ff VLINK=#000077 ALINK=#ff0000>
<a href="index.html">Contents</a> | <a href="javalang.doc8.html">Prev</a> | <a href="javalang.doc10.html">Next</a> | <a href="j.index.doc1.html">Index</a>
<hr><br>
<a name="14390"></a>
<center><h1>20.10 The Class <code>java.lang.Double</code></h1></center>
<pre><a name="14389"></a>public final class <code><b>Double</b></code> extends Number {
<a name="3591"></a> public static final double <code><b>MIN_VALUE</b></code> =<br>
5e-324;
<a name="3592"></a> public static final double <code><b>MAX_VALUE</b></code> =
<a name="31096"></a>      1.7976931348623157e+308;
<a name="2521"></a> public static final double <code><b>NEGATIVE_INFINITY</b></code> = -1.0/0.0;
<a name="3585"></a> public static final double <code><b>POSITIVE_INFINITY</b></code> = 1.0/0.0;
<a name="2522"></a> public static final double <code><b>NaN</b></code> = 0.0/0.0;
<a name="2525"></a> public <code><b>Double</b></code>(double value);
<a name="2526"></a> public <code><b>Double</b></code>(String s)<br>
throws NumberFormatException;
<a name="2527"></a> public String <code><b>toString</b></code>();
<a name="2528"></a> public boolean <code><b>equals</b></code>(Object obj);
<a name="2529"></a> public int <code><b>hashCode</b></code>();
<a name="2530"></a> public int <code><b>intValue</b></code>();
<a name="2531"></a> public long <code><b>longValue</b></code>();
<a name="2532"></a> public float <code><b>floatValue</b></code>();
<a name="2533"></a> public double <code><b>doubleValue</b></code>();
<a name="5907"></a> public static String <code><b>toString</b></code>(double d);
<a name="2534"></a> public static Double <code><b>valueOf</b></code>(String s)<br>
throws NullPointerException, NumberFormatException;
<a name="2535"></a> public boolean <code><b>isNaN</b></code>();
<a name="2536"></a> public static boolean <code><b>isNaN</b></code>(double v);
<a name="2537"></a> public boolean <code><b>isInfinite</b></code>();
<a name="2538"></a> public static boolean <code><b>isInfinite</b></code>(double v);
<a name="2547"></a> public static long <code><b>doubleToLongBits</b></code>(double value);
<a name="2548"></a> public static double <code><b>longBitsToDouble</b></code>(long bits);
<a name="2555"></a>}
</pre><a name="3571"></a>
<p><font size=+1><strong>20.10.1 </strong> <code>public static final double <code><b>MIN_VALUE</b></code> = 5e-324;</code></font>
<p>
<a name="3572"></a>
The constant value of this field is the smallest positive nonzero value of type
<code>double</code>.  It is equal to the value returned by <code>Double.longBitsToDouble(0x1L)</code>.
<p><a name="3573"></a>
<p><font size=+1><strong>20.10.2 </strong> <code>public static final double <code><b>MAX_VALUE</b></code> =      1.7976931348623157e+308;</code></font>
<p>
<a name="31109"></a>
The constant value of this field is the largest positive finite value of type <code>double</code>.
It is equal to the returned by:
<p><pre><a name="31114"></a><code>Double.longBitsToDouble(0x7fefffffffffffffL)
</code></pre><a name="31110"></a>
<p><font size=+1><strong>20.10.3 </strong> <code>public static final double <code><b>NEGATIVE_INFINITY</b></code> = -1.0/0.0;</code></font>
<p>
<a name="3623"></a>
The constant value of this field is the negative infinity of type <code>double</code>. It is equal
to the value returned by <code>Double.longBitsToDouble(0xfff0000000000000L)</code>.
<p><a name="3579"></a>
<p><font size=+1><strong>20.10.4 </strong> <code>public static final double <code><b>POSITIVE_INFINITY</b></code> = 1.0/0.0;</code></font>
<p>
<a name="3633"></a>
The constant value of this field is the positive infinity of type <code>double</code>. It is equal to
the value returned by <code>Double.longBitsToDouble(0x7ff0000000000000L)</code>.
<p><a name="13844"></a>
<p><font size=+1><strong>20.10.5 </strong> <code>public static final double <code><b>NaN</b></code> = 0.0/0.0;</code></font>
<p>
<a name="3637"></a>
The constant value of this field is the Not-a-Number of type <code>double</code>. It is equal to
the value returned by <code>Double.longBitsToDouble(0x7ff8000000000000L)</code>.
<p><a name="1496"></a>
<p><font size=+1><strong>20.10.6 </strong> <code>public <code><b>Double</b></code>(double value)</code></font>
<p>
<a name="3696"></a>
This constructor initializes a newly created <code>Double</code> object so that it represents the
primitive value that is the argument.
<p><a name="1497"></a>
<p><font size=+1><strong>20.10.7 </strong> <code>public <code><b>Double</b></code>(String s)<br>throws NumberFormatException</code></font>
<p>
<a name="3779"></a>
This constructor initializes a newly created <code>Double</code> object so that it represents the
floating-point value of type <code>double</code> represented by the string. The string is converted
to a <code>double</code> value in exactly the manner used by the <code>valueOf</code> method
<a href="javalang.doc8.html#7256">(§20.9.17)</a>.
<p><a name="1517"></a>
<p><font size=+1><strong>20.10.8 </strong> <code>public String <code><b>toString</b></code>()</code></font>
<p>
<a name="7320"></a>
The primitive <code>double</code> value represented by this <code>Double</code> object is converted to a
string exactly as if by the method <code>toString</code> of one argument <a href="javalang.doc9.html#5899">(§20.10.15)</a>.
<p><a name="3971"></a>
Overrides the <code>toString</code> method of <code>Object</code> <a href="javalang.doc1.html#1152">(§20.1.2)</a>.<p>
<a name="1518"></a>
<p><font size=+1><strong>20.10.9 </strong> <code>public boolean <code><b>equals</b></code>(Object obj)</code></font>
<p>
<a name="4658"></a>
The result is <code>true</code> if and only if the argument is not <code>null</code> and is a <code>Double</code> object
that represents the same <code>double</code> value as this <code>Double</code> object. For this purpose,
two <code>double</code> values are considered to be the same if and only if the method
<code>doubleToLongBits</code>  <a href="javalang.doc9.html#13863">(§20.10.21)</a> returns the same <code>long</code> value when applied to
each. Note that even though the <code>==</code> operator returns <code>false</code> if both operands are
NaN, this <code>equals</code> method will return <code>true</code> if this <code>Double</code> object and the argument
are both <code>Double</code> objects that represent NaN. On the other hand, even though the
<code>==</code> operator returns <code>true</code> if one operand is positive zero and the other is negative
zero, this <code>equals</code> method will return <code>false</code> if this <code>Double</code> object and the argument
represent zeroes of different sign. This allows hashtables to operate properly.
<p><a name="3978"></a>
Overrides the <code>equals</code> method of <code>Object</code> <a href="javalang.doc1.html#14865">(§20.1.3)</a>.<p>
<a name="1519"></a>
<p><font size=+1><strong>20.10.10 </strong> <code>public int <code><b>hashCode</b></code>()</code></font>
<p>
<a name="4745"></a>
The result is the exclusive OR of the two halves of the long integer bit representation,
exactly as produced by the method <code>doubleToLongBits</code> <a href="javalang.doc9.html#13863">(§20.10.21)</a>, of the
primitive <code>double</code> value represented by this <code>Double</code> object. That is, the hashcode is
the value of the expression:
<p><pre><a name="4746"></a>(int)(v^(v>>>32))
</pre><a name="4767"></a>
where <code>v</code> is defined by:
<p><pre><a name="4768"></a>long v = Double.doubleToLongBits(this.longValue());
</pre><a name="4061"></a>
Overrides the <code>hashCode</code> method of <code>Object</code> <a href="javalang.doc1.html#13784">(§20.1.4)</a>.<p>
<a name="1520"></a>
<p><font size=+1><strong>20.10.11 </strong> <code>public int <code><b>intValue</b></code>()</code></font>
<p>
<a name="4588"></a>
The <code>double</code> value represented by this <code>Double</code> object is converted <a href="5.doc.html#175672">(§5.1.3)</a> to type
<code>int</code> and the result of the conversion is returned.
<p><a name="4306"></a>
Overrides the <code>intValue</code> method of <code>Number</code> <a href="javalang.doc5.html#3376">(§20.6.1)</a>.<p>
<a name="1521"></a>
<p><font size=+1><strong>20.10.12 </strong> <code>public long <code><b>longValue</b></code>()</code></font>
<p>
<a name="4599"></a>
The <code>double</code> value represented by this <code>Double</code> object is converted <a href="5.doc.html#175672">(§5.1.3)</a> to type
<code>long</code> and the result of the conversion is returned.
<p><a name="4336"></a>
Overrides the <code>longValue</code> method of <code>Number</code> <a href="javalang.doc5.html#3434">(§20.6.2)</a>.<p>
<a name="1522"></a>
<p><font size=+1><strong>20.10.13 </strong> <code>public float <code><b>floatValue</b></code>()</code></font>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -