- Math类
- 1 字段摘要
- 2 常用方法
1 字段摘要位于java.lang包下
| 字段名 | 解释 |
|---|---|
| static final double E | 自然指数e |
| static final double PI | 圆周率π |
Math中的方法均为静态方法,通过类名就可以调用。
| 方法名称 | 解释 |
|---|---|
| Math.abs() | 求绝对值 |
| Math.max() | 求最大值,最小值用min |
| Math.pow(x,y) | 计算x的y次方,x^y |
| Math.sqrt(x) | 计算x的算数平方根 |
| Math.ceil() | 向上取整,例如Math.ceil(3.1),结果为4.0 |
| Math.floor() | 向下取整,例如Math.floor(3,9),结果为3.0 |
| Math.round() | 四舍五入,例如Math.round(3.4),结果为3 |



