learning java Math类

output:
//取整,返回小于目标数的最大整数
System.out.println(Math.floor(-1.2));
// 取整,返回在于目标数的最大整数
System.out.println(Math.ceil(1.2));
// 四舍五入取整
System.out.println(Math.round(1.6));
System.out.println(Math.round(1.5));
System.out.println(Math.round(1.4));

System.out.println(Math.IEEEremainder(5,3));
System.out.println(Math.IEEEremainder(5,2));

//计算平方
System.out.println(Math.pow(3,4));
//计得平方根
System.out.println(Math.sqrt(4));
// 计算立方根
System.out.println(Math.cbrt(27));

System.out.println(Math.copySign(1.2,-1.0));

System.out.println(Math.nextAfter(1.4,1.0));

System.out.println(Math.nextUp(1.3));
 
-2.0
2.0
2
2
1
-1.0
1.0
81.0
2.0
3.0
-1.2
1.3999999999999997
1.3000000000000003

 

posted @ 2019-07-25 16:31  嵌入式实操  阅读(162)  评论(0编辑  收藏  举报