对比总结JavaScript Math对象的一些方法
//Math.round(): “附近、周围”,求一个附近的整数
//小数点后第一位<5
正数:
Math.round(11.46)=11
负数:
Math.round(-11.46)=-11
//小数点后第一位>5
正数:
Math.round(11.68)=12
负数:
Math.round(-11.68)=-12
//小数点后第一位=5
正数:
Math.round(11.5)=12
负数:
Math.round(-11.5)=-11
//Math.ceil(): “天花板”
Math.ceil(11.46)=Math.ceil(11.68)=Math.ceil(11.5)=12
Math.ceil(-11.46)=Math.ceil(-11.68)=Math.ceil(-11.5)=-11
//Math.floor(): “地板”
Math.ceil(11.46)=Math.ceil(11.68)=Math.ceil(11.5)=11
Math.ceil(-11.46)=Math.ceil(-11.68)=Math.ceil(-11.5)=-12
//Math.random()
>返回 0.0 ~ 1.0 之间的一个伪随机数