javascript操作Math對象的方法總結

來源:互聯網
上載者:User

//數學函數--abs         返回數位絕對值    var a;    /*a = Math.abs(-12);    alert(a);            //12    //數學函數--acos        返回數的反餘弦數    a = Math.acos(數值運算式);       //數學函數--asin        返回數的正餘弦數    a = Math.asin(數值運算式);    //數學函數--atan        返回數的反正切數    a = Math.atan(數值運算式);    //數學函數--ceil        返回大於等於其數字參數的最小整數。    a = Math.ceil(-10.1);    alert(a);            //-10    //數學函數--cos            返回數的餘弦值。    a = Math.cos(數值運算式);    //數學函數--exp            返回 e(自然對數的底)的冪。        a = Math.exp(4);    alert(a);            //54.59815003314423    //數學函數--floor        返回小於等於其數值參數的最大整數    a = Math.floor(10.2);    alert(a);            //10    //數學函數--log            返回數位自然對數    a = Math.log(4);    alert(a);            //1.3862943611198906    //數學函數--max            返回給出的零個或多個數值運算式中較大值。    a = Math.max(1,20,3);    alert(a);            //20    //數學函數--min            返回給出的零個或多個數值運算式中較小值。    a = Math.min(0,-1,10);    alert(a);            //-1    //數學函數--pow            返回底運算式的指定次冪。    a = Math.pow(10,2);    alert(a);            //100    //數學函數--random        返回0與1之間的偽隨機數    a = Math.random();    alert(a);    //數學函數--round        返回四捨五入的整數值    a = Math.round(10.52);    alert(a);            //11    //數學函數--sin            返回數位正弦值。    a = Math.sin(數值運算式);    //數學函數--sqrt        返回數位平方根    a = Math.sqrt(25);    alert(a);            //5    //數學函數--tan            返回數位正切值    a = Math.tan(數值運算式);       */

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.