📄 math.html
字号:
round</H3><PRE>public static long <B>round</B>(double a)</PRE><DL><DD>Returns the closest <code>long</code> to the argument. The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to type <code>long</code>. In other words, the result is equal to the value of the expression: <p><pre>(long)Math.floor(a + 0.5d)</pre> <p> Special cases: <ul><li>If the argument is NaN, the result is 0. <li>If the argument is negative infinity or any value less than or equal to the value of <code>Long.MIN_VALUE</code>, the result is equal to the value of <code>Long.MIN_VALUE</code>. <li>If the argument is positive infinity or any value greater than or equal to the value of <code>Long.MAX_VALUE</code>, the result is equal to the value of <code>Long.MAX_VALUE</code>.</ul><DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - a <code>double</code> value.<DT><B>Returns:</B><DD>the value of the argument rounded to the nearest <code>long</code> value.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Long.html#MAX_VALUE"><CODE>Long.MAX_VALUE</CODE></A>, <A HREF="../../java/lang/Long.html#MIN_VALUE"><CODE>Long.MIN_VALUE</CODE></A></DL></DD></DL><HR><A NAME="random()"><!-- --></A><H3>random</H3><PRE>public static double <B>random</B>()</PRE><DL><DD>Returns a <code>double</code> value with a positive sign, greater than or equal to <code>0.0</code> and less than <code>1.0</code>. Returned values are chosen pseudorandomly with (approximately) uniform distribution from that range. <p> When this method is first called, it creates a single new pseudorandom-number generator, exactly as if by the expression <blockquote><pre>new java.util.Random</pre></blockquote> This new pseudorandom-number generator is used thereafter for all calls to this method and is used nowhere else. <p> 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.<DD><DL><DT><B>Returns:</B><DD>a pseudorandom <code>double</code> greater than or equal to <code>0.0</code> and less than <code>1.0</code>.<DT><B>See Also: </B><DD><A HREF="../../java/util/Random.html#nextDouble()"><CODE>Random.nextDouble()</CODE></A></DL></DD></DL><HR><A NAME="abs(int)"><!-- --></A><H3>abs</H3><PRE>public static int <B>abs</B>(int a)</PRE><DL><DD>Returns the absolute value of an <code>int</code> value. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned. <p> Note that if the argument is equal to the value of <code>Integer.MIN_VALUE</code>, the most negative representable <code>int</code> value, the result is that same value, which is negative.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - an <code>int</code> value.<DT><B>Returns:</B><DD>the absolute value of the argument.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Integer.html#MIN_VALUE"><CODE>Integer.MIN_VALUE</CODE></A></DL></DD></DL><HR><A NAME="abs(long)"><!-- --></A><H3>abs</H3><PRE>public static long <B>abs</B>(long a)</PRE><DL><DD>Returns the absolute value of a <code>long</code> value. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned. <p> Note that if the argument is equal to the value of <code>Long.MIN_VALUE</code>, the most negative representable <code>long</code> value, the result is that same value, which is negative.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - a <code>long</code> value.<DT><B>Returns:</B><DD>the absolute value of the argument.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Long.html#MIN_VALUE"><CODE>Long.MIN_VALUE</CODE></A></DL></DD></DL><HR><A NAME="abs(float)"><!-- --></A><H3>abs</H3><PRE>public static float <B>abs</B>(float a)</PRE><DL><DD>Returns the absolute value of a <code>float</code> value. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned. Special cases: <ul><li>If the argument is positive zero or negative zero, the result is positive zero. <li>If the argument is infinite, the result is positive infinity. <li>If the argument is NaN, the result is NaN.</ul> In other words, the result is equal to the value of the expression: <p><pre>Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))</pre><DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - a <code>float</code> value.<DT><B>Returns:</B><DD>the absolute value of the argument.</DL></DD></DL><HR><A NAME="abs(double)"><!-- --></A><H3>abs</H3><PRE>public static double <B>abs</B>(double a)</PRE><DL><DD>Returns the absolute value of a <code>double</code> value. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned. Special cases: <ul><li>If the argument is positive zero or negative zero, the result is positive zero. <li>If the argument is infinite, the result is positive infinity. <li>If the argument is NaN, the result is NaN.</ul> In other words, the result is equal to the value of the expression: <p><pre>Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1)</pre><DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - a <code>double</code> value.<DT><B>Returns:</B><DD>the absolute value of the argument.</DL></DD></DL><HR><A NAME="max(int, int)"><!-- --></A><H3>max</H3><PRE>public static int <B>max</B>(int a, int b)</PRE><DL><DD>Returns the greater of two <code>int</code> values. That is, the result is the argument closer to the value of <code>Integer.MAX_VALUE</code>. If the arguments have the same value, the result is that same value.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - an <code>int</code> value.<DD><CODE>b</CODE> - an <code>int</code> value.<DT><B>Returns:</B><DD>the larger of <code>a</code> and <code>b</code>.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Long.html#MAX_VALUE"><CODE>Long.MAX_VALUE</CODE></A></DL></DD></DL><HR><A NAME="max(long, long)"><!-- --></A><H3>max</H3><PRE>public static long <B>max</B>(long a, long b)</PRE><DL><DD>Returns the greater of two <code>long</code> values. That is, the result is the argument closer to the value of <code>Long.MAX_VALUE</code>. If the argumens have the same value, the result is that same value.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - a <code>long</code> value.<DD><CODE>b</CODE> - a <code>long</code> value.<DT><B>Returns:</B><DD>the larger of <code>a</code> and <code>b</code>.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Long.html#MAX_VALUE"><CODE>Long.MAX_VALUE</CODE></A></DL></DD></DL><HR><A NAME="max(float, float)"><!-- --></A><H3>max</H3><PRE>public static float <B>max</B>(float a, float b)</PRE><DL><DD>Returns the greater of two <code>float</code> values. That is, the result is the argument closer to positive infinity. If the arguments have the same value, the result is that same value. If either value is <code>NaN</code>, then the result is <code>NaN</code>. Unlike the the numerical comparison operators, this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other negative zero, the result is positive zero.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - a <code>float</code> value.<DD><CODE>b</CODE> - a <code>float</code> value.<DT><B>Returns:</B><DD>the larger of <code>a</code> and <code>b</code>.</DL></DD></DL><HR><A NAME="max(double, double)"><!-- --></A><H3>max</H3><PRE>public static double <B>max</B>(double a, double b)</PRE><DL><DD>Returns the greater of two <code>double</code> values. That is, the result is the argument closer to positive infinity. If the arguments have the same value, the result is that same value. If either value is <code>NaN</code>, then the result is <code>NaN</code>. Unlike the the numerical comparison operators, this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other negative zero, the result is positive zero.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - a <code>double</code> value.<DD><CODE>b</CODE> - a <code>double</code> value.<DT><B>Returns:</B><DD>the larger of <code>a</code> and <code>b</code>.</DL></DD></DL><HR><A NAME="min(int, int)"><!-- --></A><H3>min</H3><PRE>public static int <B>min</B>(int a, int b)</PRE><DL><DD>Returns the smaller of two <code>int</code> values. That is, the result the argument closer to the value of <code>Integer.MIN_VALUE</code>. If the arguments have the same value, the result is that same value.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - an <code>int</code> value.<DD><CODE>b</CODE> - an <code>int</code> value.<DT><B>Returns:</B><DD>the smaller of <code>a</code> and <code>b</code>.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Long.html#MIN_VALUE"><CODE>Long.MIN_VALUE</CODE></A></DL></DD></DL><HR><A NAME="min(long, long)"><!-- --></A><H3>min</H3><PRE>public static long <B>min</B>(long a, long b)</PRE><DL><DD>Returns the smaller of two <code>long</code> values. That is, the result is the argument closer to the value of <code>Long.MIN_VALUE</code>. If the arguments have the same value, the result is that same value.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - a <code>long</code> value.<DD><CODE>b</CODE> - a <code>long</code> value.<DT><B>Returns:</B><DD>the smaller of <code>a</code> and <code>b</code>.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Long.html#MIN_VALUE"><CODE>Long.MIN_VALUE</CODE></A></DL></DD></DL><HR><A NAME="min(float, float)"><!-- --></A><H3>min</H3><PRE>public static float <B>min</B>(float a, float b)</PRE><DL><DD>Returns the smaller of two <code>float</code> values. That is, the result is the value closer to negative infinity. If the arguments have the same value, the result is that same value. If either value is <code>NaN</code>, then the result is <code>NaN</code>. Unlike the the numerical comparison operators, this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other is negative zero, the result is negative zero.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - a <code>float</code> value.<DD><CODE>b</CODE> - a <code>float</code> value.<DT><B>Returns:</B><DD>the smaller of <code>a</code> and <code>b.</code></DL></DD></DL><HR><A NAME="min(double, double)"><!-- --></A><H3>min</H3><PRE>public static double <B>min</B>(double a, double b)</PRE><DL><DD>Returns the smaller of two <code>double</code> values. That is, the result is the value closer to negative infinity. If the arguments have the same value, the result is that same value. If either value is <code>NaN</code>, then the result is <code>NaN</code>. Unlike the the numerical comparison operators, this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other is negative zero, the result is negative zero.<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - a <code>double</code> value.<DD><CODE>b</CODE> - a <code>double</code> value.<DT><B>Returns:</B><DD>the smaller of <code>a</code> and <code>b</code>.</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Math.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../java/lang/Long.html"><B>PREV CLASS</B></A> <A HREF="../../java/lang/Number.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="Math.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="http://java.sun.com/products/jdk/1.3/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.<br>Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road<br>Palo Alto, California, 94303, U.S.A. All Rights Reserved.</font></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -