美文网首页
JS中的几种数学方法

JS中的几种数学方法

作者: build1024 | 来源:发表于2017-06-04 02:03 被阅读0次

//alert(Math.abs(-9));      // 绝对值

//alert(Math.ceil(2.6)) ;   // Math.ceil( )是向上取整的意思 ,弹出结果是3

//alert(Math.floor(-0.6));// 向下取整的意思 ,弹出结果是-1

//alert(Math.sqrt(16));        //开平方的意思,弹出结果是4

//alert(Math.pow(3,4));     //幂的意思,弹出结果是81,因为3的4次幂是81

//alert(Math.round(3.333));    //四舍五入,只保留整数部分,结果是3

//alert(Math.round(1.511));   //四舍五入,只保留整数部分

相关文章

网友评论

      本文标题:JS中的几种数学方法

      本文链接:https://www.haomeiwen.com/subject/ouqvfxtx.html