JS数值精度函数

  var a = 3.7;
  //  alert(parseInt(a));  //去掉小数部分---3
   // alert(Math.ceil(a));   //4  向上取整,3.01返回的也是4, 3.6返回的也是4
    alert(Math.floor(a));   //向下取去整 ----3

    // alert(Math.round(a));   // 四舍五入

 

posted @ 2017-09-28 10:08  千寻的天空之城  阅读(611)  评论(0编辑  收藏  举报