Math.floor() :向下取整;
Math.ceil() : 向上取整;
Math.around() : 四舍五入;
例:
alert(Math.ceil(5.9)); //6
alert(Math.ceil(5.5)); //6
alert(Math.ceil(5.1)); //6
alert(Math.round(5.9)); //6
alert(Math.round(5.5)); //6
alert(Math.round(5.1)); //5
alert(Math.floor(5.9)); //5
alert(Math.floor(5.5)); //5
alert(Math.floor(5.1)); //5
js 中floor ,ceil ,around 的使用
最新推荐文章于 2024-02-23 22:02:20 发布