posts - 54,  comments - 1,  trackbacks - 0

          Math類保留了所有用于幾何學,三角學及幾種一般用途的浮點函數.包括:三屆函數,指數函數,舍入函數.比較常用到的有下面幾個方法:

          • abs(arg) : 返回arg絕對值,arg可以是:int,long,float,double.
            Math.abs(-30.5)           == 30.5
            Math.abs(
          -100.0989)   == 100.0989
          • ceil(double arg) : 返回>=arg的最小整數.
            Math.ceil(30.4)        == 31.0
            Math.ceil(
          -8.0989)   == -8.0

          floor(double arg) : 返回<=arg最大整數.

            Math.floor(30.4)        == 30.0
            Math.floor(
          -8.0989)   == -9.0

          max(x,y) : 返回x和y中的最大值.

          • min(x,y) : 返回x和y中的最小值.
          • rint(double arg) : 返回最接近arg的整數值.
            Math.rint(30.4)        == 30.0
            Math.rint(
          30.5)        == 31.0
            Math.rint(
          30.51)      == 31.0
            Math.rint(
          -8.0989)   == -8.0
            Math.rint(
          -8.5)         == -8.0
            Math.rint(
          -8.5989)   == -9.0

          round(arg) : 返回arg的只入不舍的最近整數值.

            Math.round(30.4)        == 30
            Math.round(
          30.5)        == 31
            Math.round(
          30.51)      == 31
            Math.round(
          -8.0989)   == -8
            Math.round(
          -8.5)         == -8
            Math.round(
          -8.5989)   == -9

          random() : 返回一個介于0與1之間的偽隨機數.大多數情況下適應Random類產生隨機數.

          Math.random()   == 0.30536023864301465   // 每次結果不同

          toRadians(double angle) : 將角度轉換為弧度.

          Math.toRadians(120.0)  == 2.0943951023931953  // 120.0 角度 = 2.0943951023931953 弧度

          toDegrees(double angle) : 將弧度轉換為角度.

          Math.toDegrees(1)  == 57.29577951308232  // 1 弧度 = 57.29577951308232 角度
          posted on 2005-09-08 10:44 ZhuJun 閱讀(477) 評論(0)  編輯  收藏 所屬分類: 開發手記

          蜀中人氏,躬耕于珠海

          <2005年9月>
          28293031123
          45678910
          11121314151617
          18192021222324
          2526272829301
          2345678

          常用鏈接

          留言簿(2)

          隨筆分類(71)

          隨筆檔案(54)

          博客

          文檔

          站點

          論壇

          搜索

          •  

          積分與排名

          • 積分 - 51266
          • 排名 - 974

          最新評論

          閱讀排行榜

          主站蜘蛛池模板: 宜城市| 锦屏县| 德庆县| 浑源县| 太保市| 肇源县| 辽阳县| 盐边县| 伽师县| 化德县| 奉节县| 延边| 公主岭市| 安义县| 石台县| 宁德市| 抚松县| 西宁市| 巴彦淖尔市| 辽阳市| 黄骅市| 吴堡县| 长宁县| 安远县| 霍林郭勒市| 家居| 古丈县| 五常市| 资源县| 西乌珠穆沁旗| 昌江| 灵川县| 九龙城区| 鄂州市| 禄劝| 伊春市| 漯河市| 曲靖市| 达日县| 新晃| 清原|