有float类型的
向上取整:Math.ceil() //只要有小数都+1
向下取整:Math.floor() //不取小数
四舍五入:Math.round() //四舍五入
有float,向上取整:Math.ceil() //只要有小数都+1
向下取整:Math.floor() //不取小数
四舍五入:Math.round() //四舍五入
float类型的有,对doublejava.lang.Math.round方法就是四舍五入。
去尾法是java.lang.Math.floor
double a = 35;
double b = 20;
double c = a/b; //等于1.75
System.out.println(c); //输出1.75
System.out.println(Math.ceil(c)); //向上取整输出2.0
System.out.println(Math.floor(c)); //向下取整输出1.0
System.out.println(Math.round(c)); //四舍五入取整输出2.0