javascript操作Math對象的方法總結
//數學函數--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(數值表達式); */</pre><br />
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!