如何學(xué)好java

          如何學(xué)好java,其實(shí)很簡單,只要用心體會(huì),慢慢積累!
          posts - 106, comments - 7, trackbacks - 0, articles - 3
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          Java Math的 floor,round和ceil的總結(jié)

          Posted on 2011-04-22 17:44 哈希 閱讀(148) 評(píng)論(0)  編輯  收藏 所屬分類: java 代碼
          floor 向下取整
          ceil  向上取整
          round 則是4舍5入的計(jì)算,round方法,它表示“四舍五入”,算法為Math.floor(x+0.5),即將原來的數(shù)字加上0.5后再向下取整,所以,Math.round(11.5)的結(jié)果為12,Math.round(-11.5)的結(jié)果為-11。

          Math.floor(1.4)=1.0
          Math.round(1.4)=1
          Math.ceil(1.4)=2.0
          Math.floor(1.5)=1.0
          Math.round(1.5)=2
          Math.ceil(1.5)=2.0
          Math.floor(1.6)=1.0
          Math.round(1.6)=2
          Math.ceil(1.6)=2.0
          Math.floor(-1.4)=-2.0
          Math.round(-1.4)=-1
          Math.ceil(-1.4)=-1.0
          Math.floor(-1.5)=-2.0
          Math.round(-1.5)=-1
          Math.ceil(-1.5)=-1.0
          Math.floor(-1.6)=-2.0
          Math.round(-1.6)=-2
          Math.ceil(-1.6)=-1.0
          主站蜘蛛池模板: 太保市| 井陉县| 商河县| 高唐县| 淮南市| 三江| 七台河市| 长治县| 濉溪县| 始兴县| 唐海县| 徐州市| 津市市| 阜康市| 西丰县| 阜城县| 乡宁县| 吴桥县| 南投县| 商南县| 邵东县| 许昌市| 密云县| 延吉市| 冀州市| 伊吾县| 稻城县| 舒兰市| 临汾市| 英山县| 曲周县| 卫辉市| 鄯善县| 金湖县| 县级市| 金川县| 陵水| 武义县| 宁阳县| 新竹市| 土默特左旗|