Math
Math提供了数学计算的静态方法
序号 | 方法 | 描述 |
---|---|---|
1 | abs() | 返回参数的绝对值。Math.abs(-9) |
2 | ceil() | 返回大于等于( >= )给定参数的的最小整数。 |
3 | floor() | 返回小于等于(<=)给定参数的最大整数 。 |
4 | rint() | 返回与参数最接近的整数。返回类型为double。 |
5 | round() | 它表示四舍五入,算法为 Math.floor(x+0.5),即将原来的数字加上 0.5 后再向下取整,所以,Math.round(11.5) 的结果为12,Math.round(-11.5) 的结果为-11。 |
6 | min | 返回两个参数中的最小值。Math.min(1,3) |
7 | max | 返回两个参数中的最大值。Math.max(1.3,6) |
8 | exp | 返回自然数底数e的参数次方。Math.exp(1) |
9 | log | 返回参数的自然数为底数的对数值。Math.log(2.718281828459045);log10 返回参数的10为底数的对数值。Math.log10(10) |
10 | pow | 返回第一个参数的第二个参数次方。Math.pow(2,10) |
11 | sqrt | 求参数的算术平方根。Math.sqrt(2) |
12 | sin() | 求指定double类型参数的正弦值。Math.sin(Math.PI/6) |
13 | cos() | 求指定double类型参数的余弦值。 |
14 | tan() | 求指定double类型参数的正切值。 |
15 | asin() | 求指定double类型参数的反正弦值。 |
16 | acos() | 求指定double类型参数的反余弦值。 |
17 | atan() | 求指定double类型参数的反正切值。 |
18 | atan2() | 将笛卡尔坐标转换为极坐标,并返回极坐标的角度值。 |
19 | toDegrees() | 将参数转化为角度。 |
20 | toRadians() | 将角度转换为弧度。 |
21 | random() | 返回一个随机数。 |
PI Math.PI
E Math.E
总结
- Math:数学运算
Random:生成伪随机数
SecureRandom:生成安全的随机数
BigInteger:表示任意大小的证书
BigDecimal:表示任意精度的浮点数
BigInteger和BigDecimal都继承自Number
(http://www.runoob.com/java/java-number.html){http://www.runoob.com/java/java-number.html}