美文网首页
Math方法

Math方法

作者: 1462a2c022bc | 来源:发表于2018-10-18 14:28 被阅读0次

Math的属性PI         PI属性代表圆周率

Math.abs(x) 返回绝对值  

Math.ceil(x)  向上取整

Math.floor(x) 向下取整

Math.max(x)  返回指定值里面的最大最值

Math.min(x,y)  返回指定函数里面最小值

Math.pow(x,y)   返回x的 y 次幂的值

Math.random() 返回介于0 ~ 1之间的一个随机数,包含0不包含1。

Math.round(x)  四舍五入

获取指定范围的随机整数

function randomInt(min,max){

return Math.floor(Math.random()*(max-min+1)+min);

}

相关文章

网友评论

      本文标题:Math方法

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