JS 去掉小数点

parseInt(3.14159)    => 3

~~3.14159  => 3

 

还有:

向上取整  Math.ceil(3.14159) => 4

向下取整  Math.floor(3.14159) => 3

四舍五入  Math.round(3.14159) => 3

 

posted @ 2020-10-10 14:54  bcj7wi3kd5h1wd6  阅读(6574)  评论(0编辑  收藏  举报