posts - 19, comments - 53, trackbacks - 0, articles - 283
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          Math 取整函數(shù)

          Posted on 2009-10-17 13:42 Gavin.lee 閱讀(863) 評論(0)  編輯  收藏 所屬分類: java SE & EE
          /**
           * 取整函數(shù)
           
          */

          public class QuZheng {
              
          public static void main(String[] args) {
                  
          //四舍五入   
                  System.out.println(Math.round(3.40d));   //3
                  System.out.println(Math.round(3.60d));   //4
                  
          //上取整   
                  System.out.println(Math.ceil(3.4));   //4.0
                  
          //下取整   
                  System.out.println(Math.floor(3.40));   //3.0
                  
                  System.out.println((
          int)3.45);    //3
              }

          }
          主站蜘蛛池模板: 石台县| 南投县| 承德市| 马关县| 囊谦县| 左云县| 额敏县| 和平区| 汾西县| 合水县| 湛江市| 临澧县| 来宾市| 涞水县| 靖江市| 时尚| 沁源县| 延寿县| 宁国市| 田林县| 绵竹市| 鄱阳县| 南投市| 郎溪县| 阿拉尔市| 荆门市| 台中市| 横山县| 上思县| 青州市| 龙山县| 根河市| 滨海县| 怀宁县| 韩城市| 余姚市| 郁南县| 康定县| 改则县| 来安县| 通榆县|