欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長資訊網(wǎng)
          最全最豐富的資訊網(wǎng)站

          javascript怎么去掉小數(shù)部分

          去掉方法:1、用parseInt(),語法“parseInt(值)”;2、用ceil(),語法“Math.ceil(值)”;3、用floor(),語法“Math.floor(值)”;4、用round(),語法“Math.round(值)”。

          javascript怎么去掉小數(shù)部分

          本教程操作環(huán)境:windows7系統(tǒng)、javascript1.8.5版、Dell G3電腦。

          javascript去掉小數(shù)部分的方法

          1、使用parseInt()函數(shù)取整

          // 丟棄小數(shù)部分,保留整數(shù)部分 parseInt(3.141592654) // 3

          2、使用ceil()函數(shù)向上取整

          // 向上取整,有小數(shù)就整數(shù)部分加1 Math.ceil(3.141592654) // 4

          3、使用floor()函數(shù)向下取整

          // 向下取整,丟棄小數(shù)部分 Math.floor(3.141592654) // 3

          4、使用round()函數(shù)四舍五入

          // 四舍五入 Math.round(3.141592654) // 3

          贊(0)
          分享到: 更多 (0)
          網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號