JAVA中double转int类型按四舍五入取整(实用)

public static void main(String[] args) {
System.out.println("向上取整:" + (int) Math.ceil(96.1));// 97 (去掉小数凑整:不管小数是多少,都进一)
System.out.println("向下取整" + (int) Math.floor(96.8));// 96 (去掉小数凑整:不论小数是多少,都不进位)
System.out.println("四舍五入取整:" + Math.round(96.1));// 96 (这个好理解,不解释)
System.out.println("四舍五入取整:" + Math.round(96.8));// 97
}
————————————————

  

posted @ 2020-05-28 11:08  八英里  阅读(12457)  评论(0编辑  收藏  举报