码迷,mamicode.com
首页 > 编程语言 > 详细

java 向上、向下取整,四舍五入

时间:2018-05-28 11:34:29      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:round   1.4   IV   rgs   bsp   四舍五入   java   mat   out   

public class MathTest {

    public static void main(String[] args) {

        // 四舍五入
        long round = Math.round(1.499);
        long round2 = Math.round(1.5);
        System.out.println(round);
        System.out.println(round2);

        // 向上取整
        int s = (int)Math.ceil(1.1);
        System.out.println(s);

        // 向下取整
        System.out.println((int)Math.floor(1.6));
    }
}

 

java 向上、向下取整,四舍五入

标签:round   1.4   IV   rgs   bsp   四舍五入   java   mat   out   

原文地址:https://www.cnblogs.com/dayu007/p/9098690.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!