1 Math.floor(1.4)=1.0
2 Math.round(1.4)=1
3 Math.ceil(1.4)=2.0
4 Math.floor(1.5)=1.0
5 Math.round(1.5)=2
6 Math.ceil(1.5)=2.0
7 Math.floor(1.6)=1.0
8 Math.round(1.6)=2
9 Math.ceil(1.6)=2.0
10 Math.floor(-1.4)=-2.0
11 Math.round(-1.4)=-1
12 Math.ceil(-1.4)=-1.0
13 Math.floor(-1.5)=-2.0
14 Math.round(-1.5)=-1
15 Math.ceil(-1.5)=-1.0
16 Math.floor(-1.6)=-2.0
17 Math.round(-1.6)=-2
18 Math.ceil(-1.6)=-1.0
- floor 向下取整
- ceil 向上取整
- round 则是4舍5入的计算,round方法,它表示“四舍五入”,算法为Math.floor(x+0.5),即将原来的数字加上0.5后再向下取整,所以,Math.round(11.5)的结果为12,Math.round(-11.5)的结果为-11。