JS中的几种数学方法

//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中的几种数学方法)