完全没听说过这个小东东,可能书上忽略掉了吧。
Math.ceil()
表示向上取整;
eg:
Math.ceil(11.3)=12;Math.ceil(11.3)=12
。
Math.floor()
表示向下取整;
eg:
Math.floor(11.6)=12;Math.floor(11.6)=12
。
Math.round()
表示四舍五入;
eg:
Math.round(11.5)=12; Math.round(-11.5)=-11;
Marh.round(11.3)=11; Math.round(-11.3)=-11;
要注意四舍五入负数的例子!!!!!!!