首页
Profile
Profile
Profile
Profile
Profile

Javascript的取整操作

2011-01-15 阅读 87
数据的强制转换中取整是非常常用的一类操作了,这里作如下总结吧。 #### 舍弃小数部分,保留整数部分:
    parseInt( 3.5 )
    ```
    

直接进一,不论小数位的大小:

    Math.ceil( 3.1 )
    ```
    

四舍五入法:

    Math.round( 3.1 )
    ```
    

向下取整法,相对于直接进一法:

    Math.floor( 3.5 )
    ```


javascript 取整 parseInt 强制转换  Math ceil round floor



更新于 2023年03月28日
 
陕ICP备13008705号-1 Chat Gpt Api