1.取绝对值–Math.abs()
int i=Math.abs(-100); 得到 i=100
double i=Math.abs(-3.12); 得到 i=3.12
2.向上取整–Math.ceil()
int i=Math.abs(3.12); 得到 i=4;
3.向下取整–Math.floor()
int i=Math.floor(3.12); 得到 i=3;
4.四舍五入–Math.round()
int i=Math.round(3.2); 得到 i=3;
int i=Math.round(3.6); 得到 i=4;
小严成长日记之数学工具类Math(类方法)的使用
最新推荐文章于 2023-07-12 17:04:29 发布