無線&移動互聯網技術研發

          換位思考·····
          posts - 19, comments - 53, trackbacks - 0, articles - 283
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          Math 取整函數

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

          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
              }

          }
          主站蜘蛛池模板: 武清区| 乐清市| 龙胜| 西贡区| 双桥区| 沅陵县| 恭城| 瑞安市| 蒙阴县| 德安县| 广德县| 铜陵市| 中牟县| 呼伦贝尔市| 日土县| 武隆县| 万载县| 曲麻莱县| 桑植县| 辛集市| 马鞍山市| 额敏县| 鄢陵县| 稻城县| 综艺| 铜山县| 舞阳县| 蕲春县| 新邵县| 武穴市| 天峨县| 宜州市| 宜章县| 烟台市| 武陟县| 高淳县| 阿巴嘎旗| 扬州市| 江源县| 额敏县| 陕西省|