Java的Math类中取整数,绝对值,四舍五入方法应用
package demoMath;
public class DemoMath {
public static void main(String[] args) {
System.out.println(Math.abs(-9));//取绝对值 输出是9
System.out.println(Math.ceil(6.1));//向上取整. 输出结果:7
System.out.println(Math.floor(6.9));//向下取整.输出结果:6
System.out.println(Math.round(5.5));//四舍五入. 输出结果:6
}
}