SCJP须知:java.lang.Math

类别:Java 点击:0 评论:0 推荐:
ceil(double)
返回不小于该参数的最小整数 (最接近负无穷)的 double 型值。
floor(double)
返回不大于该参数的最大整数 (最接近正无穷)的 double 型值。
IEEEremainder(double, double)
计算两个参数按照 IEEE 754 标准规定的求余运算。
pow(double, double)
返回参数一的参数二次方。
random()
返回 0.0 到 1.0 间的随机数。
rint(double)
返回与该参数最接近的整数。 
double toDegrees(double angrad)
          Converts an angle measured in radians to an approximately equivalent angle measured in degrees. 
 double toRadians(double angdeg)
          Converts an angle measured in degrees to an approximately equivalent angle measured in radians. Math 類別

   Math 類別包括一些數字運算的方法。如指數、對數、開平方、三角函數等

Math 類別的資料欄:

l          Double E = 2.7182818284590452354

l          Double PI = η

Math 類別的方法

l          Abs(double x):傳回 x 的絕對值。X也可int long float

l          acos(double x):傳回x值的反餘弦函數值。

l          asin(double x):傳回x值的反正弦函數值。

l          atan(double x):傳回x值的反正切函數值。

l          atan2(double x, double y):傳回極座標(polar)的θ值

l          ceil(double x):傳回不小於x的最小整數值。

l          cos(double x):傳回x徑度的餘弦函數值

l          exp(double x):傳回相當於ex值

l          floor(double x):傳回不大於x的最大整數值

l          log(double x):傳回x的自然對數函數值

l          max(double x,double y):傳回x、y較大數

l          min(double x,double y):傳回x、y較小數

l          pow(double x,double y):傳回xy值

l          random():傳回亂數值

l          rint(double x):傳回最接近x的整數值

l          round(double x):傳回x的四捨五入值

l          sin(double x): 傳回x徑度的正弦函數值

l          sqrt(double x): 傳回x開平方值

l          tan(double x): 傳回x徑度的正切函數值

l          toDegrees(double angrad):傳回將angrad徑度轉換成角度

l          toRadians(double angdeg): 傳回將angdeg角度轉換成徑度

Field Summary static double E
          The double value that is closer than any other to e, the base of the natural logarithms. static double PI
          The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.  Method Summary static double abs(double a)
          Returns the absolute value of a double value. static float abs(float a)
          Returns the absolute value of a float value. static int abs(int a)
          Returns the absolute value of an int value. static long abs(long a)
          Returns the absolute value of a long value. static double acos(double a)
          Returns the arc cosine of an angle, in the range of 0.0 through pi. static double asin(double a)
          Returns the arc sine of an angle, in the range of -pi/2 through pi/2. static double atan(double a)
          Returns the arc tangent of an angle, in the range of -pi/2 through pi/2. static double atan2(double y, double x)
          Converts rectangular coordinates (x, y) to polar (r, theta). static double ceil(double a)
          Returns the smallest (closest to negative infinity) double value that is not less than the argument and is equal to a mathematical integer. static double cos(double a)
          Returns the trigonometric cosine of an angle. static double exp(double a)
          Returns Euler's number e raised to the power of a double value. static double floor(double a)
          Returns the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer. static double IEEEremainder(double f1, double f2)
          Computes the remainder operation on two arguments as prescribed by the IEEE 754 standard. static double log(double a)
          Returns the natural logarithm (base e) of a double value. static double max(double a, double b)
          Returns the greater of two double values. static float max(float a, float b)
          Returns the greater of two float values. static int max(int a, int b)
          Returns the greater of two int values. static long max(long a, long b)
          Returns the greater of two long values. static double min(double a, double b)
          Returns the smaller of two double values. static float min(float a, float b)
          Returns the smaller of two float values. static int min(int a, int b)
          Returns the smaller of two int values. static long min(long a, long b)
          Returns the smaller of two long values. static double pow(double a, double b)
          Returns the value of the first argument raised to the power of the second argument. static double random()
          Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. static double rint(double a)
          Returns the double value that is closest in value to the argument and is equal to a mathematical integer. static long round(double a)
          Returns the closest long to the argument. static int round(float a)
          Returns the closest int to the argument. static double sin(double a)
          Returns the trigonometric sine of an angle. static double sqrt(double a)
          Returns the correctly rounded positive square root of a double value. static double tan(double a)
          Returns the trigonometric tangent of an angle. static double toDegrees(double angrad)
          Converts an angle measured in radians to an approximately equivalent angle measured in degrees. static double toRadians(double angdeg)
          Converts an angle measured in degrees to an approximately equivalent angle measured in radians. 类 java.lang.Math

java.lang.Object | +----java.lang.Math public final class Math extends Object

类 Math 包含基本数学操作如指数,对数,平方根和三角函数。

为确保 Java 程序的可移植性, 此软件包中对数学函数的定义必须与某些公开的算法结果一致。 这些算法可从著名的网络程序库 netlib 中的软件包 "Freely Distributable Math Library" (fdlibm)中得到。 这些用 C 语言写成的算法按照 Java 的浮点运算规则解释执行所有的浮点运算。

该网络程序库可在 World Wide Web 的下列站点查找 http://netlib.att.com/

然后进行关键字搜索目标 "fdlibm"。

该 Java 数学程序库的版本为 fdlibm dated January 4, 1995。 fdlibm 对函数给出了多种定义 (如对 acos), 使用 "IEEE 754 core function" 版 (在以字母 e 开头的文件中)。

变量索引 E 该double 值非常接近 e, 自然对数的底数。 PI 该double 值非常接近 pi, 圆的周长与直径之比。 方法索引 abs(double) 返回 double 型值的绝对值。 abs(float) 返回 float 型值的绝对值。 abs(int) 返回 int 型值的绝对值。 abs(long) 返回 long 型值的绝对值。 acos(double) 返回一个角的反余弦值,范围 0.0 到 pi。 asin(double) 返回一个角的反正弦值, 范围 -pi/2 到 pi/2 。 atan(double) 返回一个角的反正切值, 范围 -pi/2 到 pi/2 。 atan2(double, double) 将直角坐标 (b, a) 转换为极坐标 (r, theta)。 ceil(double) 返回不小于该参数的最小整数 (最接近负无穷)的 double 型值。 cos(double) 返回一个角的余弦。 exp(double) 返回 e (即, 2.718...) 的 double 次方。 floor(double) 返回不大于该参数的最大整数 (最接近正无穷)的 double 型值。 IEEEremainder(double, double) 计算两个参数按照 IEEE 754 标准规定的求余运算。 log(double) 返回(以e为底) double 值的自然对数。 max(double, double) 返回两个 double 型值中较大的一个。 max(float, float) 返回两个 float 型值中较大的一个。 max(int, int) 返回两个 int 型值中较大的一个。 max(long, long) 返回两个 long 型值中较大的一个。 min(double, double) 返回两个 double 型值中较小的一个。 min(float, float) 返回两个 float 型值中较小的一个。 min(int, int) 返回两个 int 型值中较小的一个。 min(long, long) 返回两个 long 型值中较小的一个。 pow(double, double) 返回参数一的参数二次方。 random() 返回 0.0 到 1.0 间的随机数。 rint(double) 返回与该参数最接近的整数。 round(double) 返回与该参数最接近的 long 型数。 round(float) 返回与该参数最接近的 int 型数。 sin(double) 返回一个角的正弦。 sqrt(double) 返回 double 型值的平方根。 tan(double) 返回一个角的正切。 变量 E

public static final double E 该 double 值非常接近于 e, 自然对数的底数。

PI

public static final double PI 该double 值非常接近 pi, 圆的周长与直径之比。

方法 sin

public static native double sin(double a) 返回一个角的正弦值。

参数: a - 以弧度计算的角度。 返回值: 参数的正弦值。 cos

public static native double cos(double a) 返回一个角的余弦值。

参数: a - 以弧度计算的角度。 返回值: 参数的余弦值。 tan

public static native double tan(double a) 返回一个角的正切值。

参数: a - 以弧度计算的角度。 返回值: 参数的正切值。 asin

public static native double asin(double a) 返回一个角的反正弦值, 范围 -pi/2 到 pi/2 。

参数: a - 以弧度计算的角度。 返回值: 参数的反余弦值。 acos

public static native double acos(double a) 返回一个角的反余弦值,范围 0.0 到 pi。

参数: a - 以弧度计算的角度。 返回值: 参数的反余弦值。 atan

public static native double atan(double a) 返回一个角的反正切值, 范围 -pi/2 到 pi/2 。

参数: a - 以弧度计算的角度。 返回值: 参数的反正切值。 exp

public static native double exp(double a) 返回 e (即, 2.718...) 的 a 次方,double 型值。

参数: a - 一个 double 型值。 返回值: ea, 这里 e 是自然对数的底数。 log

public static native double log(double a) 返回 a 的(以e为底) double 型的自然对数值。

参数: a - 大于 0.0 的数。 返回值: ln a, a 的自然对数。 sqrt

public static native double sqrt(double a) 返回 a 的平方根, double 型值。

参数: a - 一个 double 型值。 返回值: a 的平方根。若参数为 NaN 或小于零, 则结果为 NaN。 IEEEremainder

public static native double IEEEremainder(double f1, double f2) 计算两个参数按照 IEEE 754 标准规定的求余运算。 余数等于 f1 - f2 × n, 这里 n 是最接近商 f1/f2 的整数,并且如果有两个同样最接近于 f1/f2,则 n 取偶数的一个。 如果余数是零, 则它的符号与第一个参数相同。

参数: f1 - 被除数。 f2 - 除数。 返回值: f1 被 f2 除的余数。 ceil

public static native double ceil(double a) 返回不小于该参数的最小整数 (最接近负无穷)的 double 型值。

参数: a - 一个 double 型值。 返回值: 返回不小于该参数的最小整数 (最接近负无穷)的 double 型值。 floor

public static native double floor(double a) 返回不大于该参数的最大整数 (最接近正无穷)的 double 型值。

参数: a - 一个 double 型值。 a - 指定值。 返回值: 返回不大于该参数的最大整数 (最接近正无穷)的 double 型值。 rint

public static native double rint(double a) 返回与该参数最接近的整数。

参数: a - 一个 double 型值。 返回值: 最接近 a 的整数的 double 型值。 如果两个 double 型值同样接近于该参数,返回值为偶数的那一个。 atan2

public static native double atan2(double a, double b) 将直角坐标 (b, a) 转换为极坐标 (r, theta)。 该方法计算 b/a 的反正切得到相位 theta, 范围 -pi 到 pi。

参数: a - 一个 double 型值。 b - 一个 double 型值。 返回值: 极坐标(r, theta)中的 theta 部分对应于 Cartesian 坐标中的点 (b, a)。 pow

public static native double pow(double a, double b) 返回以参数一为底数,参数二为指数的幂值。

若 (a == 0.0),则 b 必须大于 0.0; 否则将抛出一个异常。 如果 (a <= 0.0) 且 b 为整数,则发生异常。

参数: a - 一个 double 型值。 b - 一个 double 型值。 返回值: ab。 抛出: ArithmeticException 如果 (a == 0.0) 且 (b <= 0.0), 或如果 (a <= 0.0) 且 b 不为整数。 round

public static int round(float a) 返回与该参数最接近的 int 型数。

如果该参数为负无穷或值小于等于 Integer.MIN_VALUE, 则结果等于 Integer.MIN_VALUE。

如果该参数为正无穷或值大于等于 Integer.MAX_VALUE, 则结果等于 Integer.MAX_VALUE。

参数: a - 一个 float 型值。 返回值: 该参数四舍五入到最近的 int 型值。 参见: MAX_VALUE, MIN_VALUE round

public static long round(double a) 返回与该参数最接近的 long 型数。

如果该参数为负无穷或值小于等于 Long.MIN_VALUE, 则结果等于 Long.MIN_VALUE。

如果该参数为负无穷或值小于等于 Long.MAX_VALUE, 则结果等于 Long.MAX_VALUE。

参数: a - 一个 double 型值。 返回值: 该参数四舍五入到最近的 long 型值。 参见: MAX_VALUE, MIN_VALUE random

public static synchronized double random() 返回 0.0 到 1.0 间的随机数。 所谓的随机数发生器通常是伪随机数发生器,因为它产生的数会周期性循环。

返回值: 返回 0.0 到 1.0 间的伪随机数。 参见: nextDouble abs

public static int abs(int a) 返回 a 的 int 型的绝对值。 如果参数非负,返回该参数。如果参数为负,返回其相反数。

注意到如果该参数等于 Integer.MIN_VALUE, 可表示的最小负 int 型值, 则结果与之相等且为负。

参数: a - 一个 int 型值. 返回值: 参数的绝对值。 参见: MIN_VALUE abs

public static long abs(long a) 返回 a 的 long 型的绝对值。 如果参数非负,返回该参数。如果参数为负,返回其相反数。

注意到如果该参数等于 Long.MIN_VALUE, 可表示的最小负 long 型值, 则结果与之相等且为负。

参数: a - 一个 long型值。 返回值: 参数的绝对值。 参见: MIN_VALUE abs

public static float abs(float a) 返回 a 的 float 型的绝对值。 如果参数非负,返回该参数。如果参数为负,返回其相反数。

参数: a - 一个 float 型值。 返回值: 参数的绝对值。 abs

public static double abs(double a) 返回 a 的 double 型的绝对值。 如果参数非负,返回该参数。如果参数为负,返回其相反数。

参数: a - 一个 double 型值。 返回值: 参数的绝对值。 max

public static int max(int a, int b) 返回两个 int 型值中较大的一个。

参数: a - 一个 int 型值. b - 一个 int 型值. 返回值: a 和 b 中的较大者。 max

public static long max(long a, long b) 返回两个 long 型值中较大的一个。

参数: a - 一个 long型值。 a - 一个 long型值。 返回值: a 和 b 中的较大者。 max

public static float max(float a, float b) 返回两个 float 型值中较大的一个。 只要有一个是 NaN, 则结果是 NaN。 不象数字的比较运算符,此方法认为负零严格小于正零。

参数: a - 一个 float 型值。 b - 一个 float 型值。 返回值: a 和 b 中的较大者。 max

public static double max(double a, double b) 返回两个 double 型值中较大的一个。 只要有一个是 NaN, 则结果是 NaN。 不象数字的比较运算符,此方法认为负零严格小于正零。

参数: a - 一个 double 型值。 b - 一个 double 型值。 返回值: a 和 b 中的较大者。 min

public static int min(int a, int b) 返回两个 int 型值中较小的一个。

参数: a - 一个 int 型值. b - 一个 int 型值. 返回值: a 和 b 中的较小者。 min

public static long min(long a, long b) 返回两个 long 型值中较小的一个。

参数: a - 一个 long型值。 a - 一个 long型值。 返回值: a 和 b 中的较小者。 min

public static float min(float a, float b) 返回两个 float 型值中较小的一个。 只要有一个是 NaN, 则结果是 NaN。 不象数字的比较运算符,此方法认为负零严格小于正零。

参数: a - 一个 float 型值。 b - 一个 float 型值。 返回值: a 和 b 中的较小者。 min

public static double min(double a, double b) 返回两个 double 型值中较小的一个。 只要有一个是 NaN, 则结果是 NaN。 不象数字的比较运算符,此方法认为负零严格小于正零。

参数: a - 一个 double 型值。 b - 一个 double 型值。 返回值: a 和 b 中的较小者。 IEEEremainder toDegrees toRadians 有大写字母

本文地址:http://com.8s8s.com/it/it15596.htm