首页 > 其他 > 详细

4日6日--Math的常用方法

时间:2017-04-06 15:44:49      阅读:175      评论:0      收藏:0      [点我收藏+]

技术分享

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Math的常用方法1</title>
    <script type="text/javascript">
        var n=-10;
        console.log(Math.abs(n));//10
        console.log(Math.pow(n,2));//100
        console.log(Math.sqrt(25));//5
        //3次方根:8的1/3次方
        console.log(Math.pow(8,1/3));
        var ret=Math.sin(Math.PI/6)
        console.log(ret.toFixed(3));//保留小数点后尾数,返回string
    </script>
</head>
<body>
    
</body>
</html>

技术分享

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Math的常用方法2</title>
    <script type="text/javascript">
        var n=prompt("pls input:")*1;
        var ret=Math.floor(n);
        console.log("floor:"+ret);
        ret=Math.ceil(n);
        console.log("ceil:"+ret);
        ret=Math.round(n);
        console.log("round:"+ret);
    </script>
</head>
<body>
    
</body>
</html>

 

4日6日--Math的常用方法

原文:http://www.cnblogs.com/xinxinxinxin/p/6673512.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!