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 閱讀(473) 評論(0)  編輯  收藏 所屬分類: 開發手記

          蜀中人氏,躬耕于珠海

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

          常用鏈接

          留言簿(2)

          隨筆分類(71)

          隨筆檔案(54)

          博客

          文檔

          站點

          論壇

          搜索

          •  

          積分與排名

          • 積分 - 50989
          • 排名 - 977

          最新評論

          閱讀排行榜

          主站蜘蛛池模板: 灵璧县| 家居| 黑河市| 池州市| 五河县| 额敏县| 广河县| 偏关县| 新干县| 依安县| 隆回县| 沁水县| 如东县| 盐池县| 腾冲县| 德昌县| 惠水县| 洛川县| 赤水市| 封开县| 于都县| 兰西县| 乌什县| 邵阳县| 萝北县| 盐边县| 临安市| 汉阴县| 静安区| 天柱县| 霍林郭勒市| 佛山市| 温宿县| 常山县| 河池市| 道孚县| 张家川| 中阳县| 土默特右旗| 余干县| 福州市|