1.Math.floor()
Math.floor(11.46)=Math.floor(11.68)=Math.floor(11.5)=11.0
Math.floor(-11.46)=Math.floor(-11.68)=Math.floor(-11.5)=-12.0
2.Math.ceil()
Math.ceil(11.46)=Math.ceil(11.68)=Math.ceil(11.5)=12.0
Math.ceil(-11.46)=Math.ceil(-11.68)=Math.ceil(-11.5)=-11.0
3.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.round()还有个很重要的点,是没有小数的,通常结合Math.floor(),或Math.ceil(),将Math.floor()后的小数点去除.