⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 javalang.doc10.html

📁 java语言规范
💻 HTML
📖 第 1 页 / 共 3 页
字号:
Special cases:<p>
<ul><a name="6992"></a>
<li>If the argument is NaN, the result is <code>0</code>.
<a name="6993"></a>
<li>If the argument is negative infinity, or indeed any value less than or equal to the value of <code>Long.MIN_VALUE</code> <a href="javalang.doc6.html#2390">(&#167;20.7.1)</a>, the result is equal to the value of <code>Long.MIN_VALUE</code>.
<a name="6997"></a>
<li>If the argument is positive infinity, or indeed any value greater than or equal to the value of <code>Long.MAX_VALUE</code> <a href="javalang.doc6.html#2391">(&#167;20.7.2)</a>, the result is equal to the value of <code>Long.MAX_VALUE</code>.
</ul><a name="13965"></a>
<p><font size=+1><strong>20.11.20   </strong> <code>public static double <code><b>random</b></code>()</code></font>
<p>
<a name="7085"></a>
The result is a double value with positive sign, greater than or equal to zero but 
less than <code>1.0</code>, chosen pseudorandomly with (approximately) uniform distribution 
from that range.
<p><a name="7073"></a>
When this method is first called, it creates a single new pseudorandom-number generator, exactly as if by the expression<p>
<pre><a name="7077"></a>new java.util.Random()
</pre><a name="7078"></a>
This new pseudorandom-number generator is used thereafter for all calls to this method and is used nowhere else.<p>
<a name="7086"></a>
This method is properly synchronized to allow correct use by more than one thread. However, if many threads need to generate pseudorandom numbers at a great rate, it may reduce contention for each thread to have its own pseudorandom number generator.<p>
<a name="6676"></a>
<p><font size=+1><strong>20.11.21   </strong> <code>public static int <code><b>abs</b></code>(int a)</code></font>
<p>
<a name="6677"></a>
The result is the absolute value of the argument, if possible.
<p><a name="30562"></a>
If the argument is not negative, the argument is returned.<p>
<a name="6681"></a>
If the argument is negative, the negation of the argument is returned. Note that if the argument is equal to the value of <code>Integer.MIN_VALUE</code> <a href="javalang.doc6.html#2390">(&#167;20.7.1)</a>, the most negative representable <code>int</code> value, the result will be that same negative value.<p>
<a name="6678"></a>
<p><font size=+1><strong>20.11.22   </strong> <code>public static long <code><b>abs</b></code>(long a)</code></font>
<p>
<a name="30564"></a>
The result is the absolute value of the argument, if possible.
<p><a name="34323"></a>
If the argument is not negative, the argument is returned.<p>
<a name="34324"></a>
If the argument is negative, the negation of the argument is returned. Note that if the argument is equal to the value of <code>Long.MIN_VALUE</code> <a href="javalang.doc7.html#2397">(&#167;20.8.1)</a>, the most negative representable <code>long</code> value, the result will be that same negative value.<p>
<a name="13968"></a>
<p><font size=+1><strong>20.11.23   </strong> <code>public static float <code><b>abs</b></code>(float a)</code></font>
<p>
<a name="6703"></a>
The argument is returned with its sign changed to be positive.
<p><a name="30576"></a>
Special cases:<p>
<ul><a name="19835"></a>
<li>If the argument is positive zero or negative zero, the result is positive zero.
<a name="7334"></a>
<li>If the argument is infinite, the result is positive infinity.
<a name="6724"></a>
<li>If the argument is NaN, the result is NaN.
</ul><a name="6753"></a>
In other words, the result is equal to the value of the expression:
<p><pre><a name="6754"></a>Float.intBitsToFloat(0x7fffffff &amp; Float.floatToIntBits(a))
</pre><a name="25025"></a>
[This specification for the method <code>abs</code> is scheduled for introduction in Java version 1.1. In previous versions of Java, <code>abs(-0.0f)</code> returns <code>-0.0f</code>, which is not correct.]<p>
<a name="13969"></a>
<p><font size=+1><strong>20.11.24   </strong> <code>public static double <code><b>abs</b></code>(double a)</code></font>
<p>
<a name="6736"></a>
The argument is returned with its sign changed to be positive.
<p><a name="30578"></a>
Special cases:<p>
<ul><a name="6737"></a>
<li>If the argument is positive zero or negative zero, the result is positive zero.
<a name="6738"></a>
<li>If the argument is infinite, the result is positive infinity.
<a name="6739"></a>
<li>If the argument is NaN, the result is NaN.
</ul><a name="6757"></a>
In other words, the result is equal to the value of the expression:
<p><pre><a name="6758"></a>Double.longBitsToDouble((Double.doubleToLongBits(a)&lt;&lt;1)&gt;&gt;&gt;1)
</pre><a name="25041"></a>
[This specification for the method <code>abs</code> is scheduled for introduction in Java version 1.1. In previous versions of Java, <code>abs(-0.0d)</code> returns <code>-0.0d</code>, which is not correct.]<p>
<a name="13974"></a>
<p><font size=+1><strong>20.11.25   </strong> <code>public static int <code><b>min</b></code>(int a, int b)</code></font>
<p>
<a name="6787"></a>
The result is the smaller of the two arguments-that is, the one closer to the value 
of <code>Integer.MIN_VALUE</code> <a href="javalang.doc6.html#2390">(&#167;20.7.1)</a>. If the arguments have the same value, the 
result is that same value.
<p><a name="13975"></a>
<p><font size=+1><strong>20.11.26   </strong> <code>public static long <code><b>min</b></code>(long a, long b)</code></font>
<p>
<a name="6796"></a>
The result is the smaller of the two arguments-that is, the one closer to the value 
of <code>Long.MIN_VALUE</code> <a href="javalang.doc7.html#2397">(&#167;20.8.1)</a>. If the arguments have the same value, the result is 
that same value.
<p><a name="13976"></a>
<p><font size=+1><strong>20.11.27   </strong> <code>public static float <code><b>min</b></code>(float a, float b)</code></font>
<p>
<a name="6837"></a>
The result is the smaller of the two arguments-that is, the one closer to negative 
infinity. If the arguments have the same value, the result is that same value.
<p><a name="30580"></a>
Special cases:<p>
<ul><a name="6903"></a>
<li>If one argument is positive zero and the other is negative zero, the result is negative zero.
<a name="6845"></a>
<li>If either argument is NaN, the result is NaN.
</ul><a name="25085"></a>
[This specification for the method <code>min</code> is scheduled for introduction in Java version 1.1. In previous versions of Java, <code>min(0.0f,</code> <code>-0.0f)</code> returns <code>0.0f</code>, which is not correct.]<p>
<a name="13977"></a>
<p><font size=+1><strong>20.11.28   </strong> <code>public static double <code><b>min</b></code>(double a, double b)</code></font>
<p>
<a name="31572"></a>
The result is the smaller of the two arguments-that is, the one closer to negative 
infinity. If the arguments have the same value, the result is that same value.
<p><a name="30582"></a>
Special cases:<p>
<ul><a name="6911"></a>
<li>If one argument is positive zero and the other is negative zero, the result is negative zero.
<a name="6848"></a>
<li>If either argument is NaN, the result is NaN.
</ul><a name="25094"></a>
[This specification for the method <code>min</code> is scheduled for introduction in Java version 1.1. In previous versions of Java, <code>min(0.0d,</code> <code>-0.0d)</code> returns <code>0.0d</code>, which is not correct.]<p>
<a name="6813"></a>
<p><font size=+1><strong>20.11.29   </strong> <code>public static int <code><b>max</b></code>(int a, int b)</code></font>
<p>
<a name="6814"></a>
The result is the larger of the two arguments-that is, the one closer to the value of 
<code>Integer.MAX_VALUE</code> <a href="javalang.doc6.html#2391">(&#167;20.7.2)</a>. If the arguments have the same value, the result 
is that same value.
<p><a name="6818"></a>
<p><font size=+1><strong>20.11.30   </strong> <code>public static long <code><b>max</b></code>(long a, long b)</code></font>
<p>
<a name="6819"></a>
The result is the larger of the two arguments-that is, the one closer to the value of 
<code>Long.MAX_VALUE</code> <a href="javalang.doc7.html#14434">(&#167;20.8.2)</a>. If the arguments have the same value, the result is 
that same value.
<p><a name="6823"></a>
<p><font size=+1><strong>20.11.31   </strong> <code>public static float <code><b>max</b></code>(float a, float b)</code></font>
<p>
<a name="6852"></a>
The result is the larger of the two arguments-that is, the one closer to positive 
infinity. If the arguments have the same value, the result is that same value.
<p><a name="30584"></a>
Special cases:<p>
<ul><a name="6915"></a>
<li>If one argument is positive zero and the other is negative zero, the result is positive zero.
<a name="6853"></a>
<li>If either argument is NaN, the result is NaN.
</ul><a name="25110"></a>
[This specification for the method <code>max</code> is scheduled for introduction in Java version 1.1. In previous versions of Java, <code>max(-0.0f,</code> <code>0.0f)</code> returns <code>-0.0f</code>, which is not correct.]<p>
<a name="6824"></a>
<p><font size=+1><strong>20.11.32   </strong> <code>public static double <code><b>max</b></code>(double a, double b)</code></font>
<p>
<a name="6858"></a>
The result is the larger of the two arguments-that is, the one closer to positive 
infinity. If the arguments have the same value, the result is that same value.
<p><a name="30586"></a>
Special cases:<p>
<ul><a name="6919"></a>
<li>If one argument is positive zero and the other is negative zero, the result is positive zero.
<a name="6859"></a>
<li>If either argument is NaN, the result is NaN.
</ul><a name="31504"></a>
[This specification for the method <code>max</code> is scheduled for introduction in Java version 1.1. In previous versions of Java, <code>max(-0.0d,</code> <code>0.0d)</code> returns <code>-0.0d</code>, which is not correct.].<img src="javalang.doc.anc51.gif"><p>
<a name="25132"></a>
<p>


<hr>
<!-- This inserts footnotes--><p>
<a href="index.html">Contents</a> | <a href="javalang.doc9.html">Prev</a> | <a href="javalang.doc11.html">Next</a> | <a href="j.index.doc1.html">Index</a>
<p>
<font size=-1>Java Language Specification (HTML generated by Suzette Pelouch on February 24, 1998)<br>
<i><a href="jcopyright.doc.html">Copyright &#169 1996 Sun Microsystems, Inc.</a>
All rights reserved</i>
<br>
Please send any comments or corrections to <a href="mailto:doug.kramer@sun.com">doug.kramer@sun.com</a>
</font>
</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -