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

📄 javalang.doc10.html

📁 java语言规范
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<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.doc9.html">Prev</a> | <a href="javalang.doc11.html">Next</a> | <a href="j.index.doc1.html">Index</a>
<hr><br>
 
<a name="47547"></a>
<center><h1>20.11  The Class  <code>java.lang.Math</code></h1></center>
<a name="7093"></a>
The class <code>Math</code> contains useful basic numerical constants and methods.
<p><pre><a name="15519"></a>public final class <code><b>Math</b></code> {
<a name="15520"></a>	public static final double <code><b>E</b></code> = 2.7182818284590452354;
<a name="15444"></a>	public static final double <code><b>PI</b></code> = 3.14159265358979323846;
<a name="15445"></a>	public static double <code><b>sin</b></code>(double a);
<a name="15446"></a>	public static double <code><b>cos</b></code>(double a);
<a name="15447"></a>	public static double <code><b>tan</b></code>(double a);
<a name="15448"></a>	public static double <code><b>asin</b></code>(double a);
<a name="15449"></a>	public static double <code><b>acos</b></code>(double a);
<a name="15450"></a>	public static double <code><b>atan</b></code>(double a);
<a name="6145"></a>	public static double <code><b>atan2</b></code>(double a, double b);
<a name="15451"></a>	public static double <code><b>exp</b></code>(double a);
<a name="15452"></a>	public static double <code><b>log</b></code>(double a);
<a name="15453"></a>	public static double <code><b>sqrt</b></code>(double a);
<a name="6139"></a>	public static double <code><b>pow</b></code>(double a, double b);
<a name="15454"></a>	public static double <code><b>IEEEremainder</b></code>(double f1, double f2);
<a name="15455"></a>	public static double <code><b>ceil</b></code>(double a);
<a name="15456"></a>	public static double <code><b>floor</b></code>(double a);
<a name="15457"></a>	public static double <code><b>rint</b></code>(double a);
<a name="15460"></a>	public static int <code><b>round</b></code>(float a);
<a name="15461"></a>	public static long <code><b>round</b></code>(double a);
<a name="15462"></a>	public static double <code><b>random</b></code>();
<a name="15463"></a>	public static int <code><b>abs</b></code>(int a);
<a name="15464"></a>	public static long <code><b>abs</b></code>(long a);
<a name="15465"></a>	public static float <code><b>abs</b></code>(float a);
<a name="15466"></a>	public static double <code><b>abs</b></code>(double a);
<a name="6830"></a>	public static int <code><b>min</b></code>(int a, int b);
<a name="6831"></a>	public static long <code><b>min</b></code>(long a, long b);
<a name="6832"></a>	public static float <code><b>min</b></code>(float a, float b);
<a name="6833"></a>	public static double <code><b>min</b></code>(double a, double b);
<a name="15467"></a>	public static int <code><b>max</b></code>(int a, int b);
<a name="15468"></a>	public static long <code><b>max</b></code>(long a, long b);
<a name="15469"></a>	public static float <code><b>max</b></code>(float a, float b);
<a name="15470"></a>	public static double <code><b>max</b></code>(double a, double b);
<a name="15523"></a>}
</pre><a name="7097"></a>
To ensure portability of Java programs, the specifications of many of the numerical functions in this package require that they produce the same results as certain published algorithms. These algorithms are available from the well-known network library <code>netlib</code> as the package <code>fdlibm</code> ("Freely Distributable Math Library"). These algorithms, which are written in the C programming language, are to be understood as if executed in Java execution order with all floating-point operations following the rules of Java floating-point arithmetic.<p>
<a name="7101"></a>
The network library may be found at <code>http://netlib.att.com</code> on the World Wide Web; then perform a keyword search for <code>fdlibm</code>. The library may also be retrieved by E-mail; to begin the process, send a message containing the line:<p>
<pre><a name="7106"></a>send index from fdlibm
</pre><a name="7107"></a>
to <code>netlib@research.att.com</code>. The Java math library is defined with respect to 
the version of <code>fdlibm</code> dated 95/01/04. Where <code>fdlibm</code> provides more than one definition
for a function (such as <code>acos</code>), the "IEEE754 core function" version is to be 
used (residing in a file whose name begins with the letter <code>e</code>).
<p><a name="24987"></a>
A complete and self-contained description of the algorithms to be used for these functions will be provided in a future version of this specification. It is also anticipated that the algorithms will be coded in Java to provide a reference implementation that is not tied to <code>fdlibm</code>.<p>
<a name="13943"></a>
<p><font size=+1><strong>20.11.1   </strong> <code>public static final double <code><b>E</b></code> = 2.7182818284590452354;</code></font>
<p>
<a name="5934"></a>
The constant value of this field is the <code>double</code> value that is closer than any other 
to &#32;<i>e</i>, the base of the natural logarithms.
<p><a name="13944"></a>
<p><font size=+1><strong>20.11.2   </strong> <code>public static final double <code><b>PI</b></code> = 3.14159265358979323846;</code></font>
<p>
<a name="5938"></a>
The constant value of this field is the <code>double</code> value that is closer than any other 
to &#32;<img src="chars/pi.gif">, the ratio of the circumference of a circle to its diameter.
<p><a name="13945"></a>
<p><font size=+1><strong>20.11.3   </strong> <code>public static double <code><b>sin</b></code>(double a)</code></font>
<p>
<a name="5955"></a>
This method computes an approximation to the sine of the argument, using the 
<code>sin</code> algorithm as published in <code>fdlibm</code> (see the introduction to this section).
<p><a name="30355"></a>
Special cases:<p>
<ul><a name="6037"></a>
<li>If the argument is NaN or an infinity, then the result is NaN.
<a name="6038"></a>
<li>If the argument is positive zero, then the result is positive zero; if the argument is negative zero, then the result is negative zero.
</ul><a name="13946"></a>
<p><font size=+1><strong>20.11.4   </strong> <code>public static double <code><b>cos</b></code>(double a)</code></font>
<p>
<a name="5957"></a>
This method computes an approximation to the cosine of the argument, using the 
<code>cos</code> algorithm as published in <code>fdlibm</code> (see the introduction to this section).
<p><a name="30357"></a>
Special case:<p>
<ul><a name="6040"></a>
<li>If the argument is NaN or an infinity, then the result is NaN.
</ul><a name="13947"></a>
<p><font size=+1><strong>20.11.5   </strong> <code>public static double <code><b>tan</b></code>(double a)</code></font>
<p>
<a name="5961"></a>
This method computes an approximation to the tangent of the argument, using the 
<code>tan</code> algorithm as published in <code>fdlibm</code> (see the introduction to this section).
<p><a name="30359"></a>
Special cases:<p>
<ul><a name="6044"></a>
<li>If the argument is NaN or an infinity, then the result is NaN.
<a name="6064"></a>
<li>If the argument is positive zero, then the result is positive zero; if the argument is negative zero, then the result is negative zero.
</ul><a name="13948"></a>
<p><font size=+1><strong>20.11.6   </strong> <code>public static double <code><b>asin</b></code>(double a)</code></font>
<p>
<a name="5965"></a>
This method computes an approximation to the arc sine of the argument, using the 
a<code>sin</code> algorithm as published in <code>fdlibm</code> (see the introduction to this section).
<p><a name="30361"></a>
Special cases:<p>
<ul><a name="6054"></a>
<li>If the argument is NaN or its absolute value is greater than 1, then the result is NaN.
<a name="6068"></a>
<li>If the argument is positive zero, then the result is positive zero; if the argument is negative zero, then the result is negative zero.
</ul><a name="13949"></a>
<p><font size=+1><strong>20.11.7   </strong> <code>public static double <code><b>acos</b></code>(double a)</code></font>
<p>
<a name="5969"></a>
This method computes an approximation to the arc cosine of the argument, using 
the <code>acos</code> algorithm as published in <code>fdlibm</code> (see the introduction to this section).
<p><a name="30363"></a>
Special case:<p>
<ul><a name="6048"></a>
<li>If the argument is NaN or its absolute value is greater than 1, then the result is NaN.
</ul><a name="13950"></a>
<p><font size=+1><strong>20.11.8   </strong> <code>public static double <code><b>atan</b></code>(double a)</code></font>
<p>
<a name="5973"></a>
This method computes an approximation to the arc tangent of the argument, using 
the a<code>tan</code> algorithm as published in <code>fdlibm</code> (see the introduction to this section).
<p><a name="30365"></a>
Special cases:<p>
<ul><a name="6058"></a>
<li>If the argument is NaN, then the result is NaN.
<a name="6072"></a>
<li>If the argument is positive zero, then the result is positive zero; if the argument is negative zero, then the result is negative zero.
</ul><a name="6151"></a>
<p><font size=+1><strong>20.11.9   </strong> <code>public static double <code><b>atan2</b></code>(double y, double x)</code></font>
<p>
<a name="6155"></a>
This method computes an approximation to the arc tangent of the quotient <img src="javalang.doc.anc2.gif"> of 
the arguments, using the a<code>tan2</code> algorithm as published in <code>fdlibm</code> (see the introduction
to this section).
<p><a name="30367"></a>
Special cases:<p>
<ul><a name="6178"></a>
<li>If either argument is NaN, then the result is NaN.
<a name="6199"></a>
<li>If the first argument is positive zero and the second argument is positive, or the first argument is positive and finite and the second argument is positive infinity, then the result is positive zero.
<a name="6200"></a>
<li>If the first argument is negative zero and the second argument is positive, or the first argument is negative and finite and the second argument is positive infinity, then the result is negative zero.
<a name="6204"></a>
<li>If the first argument is positive zero and the second argument is negative, or the first argument is positive and finite and the second argument is negative infinity, then the result is the <code>double</code> value closest to <img src="javalang.doc.anc3.gif">.
<a name="6217"></a>
<li>If the first argument is negative zero and the second argument is negative, or the first argument is negative and finite and the second argument is negative infinity, then the result is the <code>double</code> value closest to <img src="javalang.doc.anc4.gif">.
<a name="6241"></a>
<li>If the first argument is positive and the second argument is positive zero or negative zero, or the first argument is positive infinity and the second argument is finite, then the result is the <code>double</code> value closest to <img src="javalang.doc.anc5.gif">.
<a name="6248"></a>
<li>If the first argument is negative and the second argument is positive zero or negative zero, or the first argument is negative infinity and the second argument is finite, then the result is the <code>double</code> value closest to <img src="javalang.doc.anc6.gif">.
<a name="6354"></a>
<li>If both arguments are positive infinity, then the result is the <code>double</code> value closest to <img src="javalang.doc.anc7.gif">.
<a name="6369"></a>
<li>If the first argument is positive infinity and the second argument is negative infinity, then the result is the <code>double</code> value closest to <img src="javalang.doc.anc9.gif">.
<a name="6376"></a>
<li>If the first argument is negative infinity and the second argument is positive infinity, then the result is the <code>double</code> value closest to <img src="javalang.doc.anc10.gif">.
<a name="6345"></a>
<li>If both arguments are negative infinity, then the result is the <code>double</code> value closest to <img src="javalang.doc.anc8.gif">.
</ul><a name="6176"></a>
<p><font size=+1><strong>20.11.10   </strong> <code>public static double <code><b>exp</b></code>(double a)</code></font>
<p>
<a name="5977"></a>
This method computes an approximation to the exponential function of the argument

⌨️ 快捷键说明

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