隨筆-59  評論-31  文章-0  trackbacks-0

          public class CeilAndFloor {
              public static void main(String[] args) {
              /*
                  這兩個寶貝函數(shù)的主要任務是截掉小數(shù)以后的位數(shù).
                  區(qū)別是: floor總是把數(shù)字變得越來越小,而ceil總是把數(shù)字變大。
                          其實名字可以理解floor是地板,ceil是天花板。
              
          */

                  System.out.println("==============Math.floor()==============");
                  System.out.println("Math.floor(99.1) = " + Math.floor(99.1));
                  System.out.println("Math.floor(-99.1) = " + Math.floor(-99.1));
                  System.out.println("Math.floor(99.9) = " + Math.floor(99.9));
                  System.out.println("Math.floor(99.9) = " + Math.floor(-99.9));
                  
                  System.out.println("\n\n==============Math.ceil()==============");
                  System.out.println("Math.ceil(99.1) = " + Math.ceil(99.1));
                  System.out.println("Math.ceil(-99.1) = " + Math.ceil(-99.1));
                  System.out.println("Math.ceil(99.9) = " + Math.ceil(99.9));
                  System.out.println("Math.ceil(99.9) = " + Math.ceil(-99.9));
                  
              }
          }
          結(jié)果
          ==============Math.floor()==============
          Math.floor(99.1) = 99.0
          Math.floor(-99.1) = -100.0
          Math.floor(99.9) = 99.0
          Math.floor(99.9) = -100.0

          ==============Math.ceil()==============
          Math.ceil(99.1) = 100.0
          Math.ceil(-99.1) = -99.0
          Math.ceil(99.9) = 100.0
          Math.ceil(99.9) = -99.0
          posted on 2012-01-05 09:20 RoyPayne 閱讀(370) 評論(0)  編輯  收藏 所屬分類: java高級
          <2012年1月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          2930311234

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          文章分類

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 囊谦县| 肃宁县| 永城市| 沾益县| 瑞安市| 宾阳县| 柏乡县| 绥化市| 会同县| 简阳市| 马龙县| 南雄市| 交口县| 萍乡市| 栾川县| 枣庄市| 嘉禾县| 江西省| 陵水| 井冈山市| 平阳县| 英吉沙县| 织金县| 东安县| 宁河县| 博爱县| 塔城市| 富平县| 六安市| 白水县| 汉川市| 甘肃省| 扎赉特旗| 铜梁县| 通道| 阜城县| 枣强县| 出国| SHOW| 商南县| 晋宁县|