int abs = Math.abs(-10); //绝对值
System.out.println(abs); //10
double ceil = Math.ceil(10.1); //向上取整
System.out.println(ceil); //11
double floor = Math.floor(10.9); //向下取整
System.out.println(floor); //10
long round = Math.round(10.1); //四舍五入
System.out.println(round); //10
int max = Math.max(10, 20); //返回两个值中的较大值
System.out.println(max); //20
int min = Math.min(10, 20); //返回两个值中的较小值
System.out.println(min); //10
double pow = Math.pow(2, 2); //返回a的b次幂
System.out.println(pow);
double random = Math.random(); //返回值为double的正值[0.0,1.0]
System.out.println(random);
最后修改:2022 年 01 月 05 日
© 允许规范转载
3 条评论
1
1
1