<script type="text/javascript">

    var x = 4.23323;//测试的数字
    var y = String(x).indexOf(".") + 1;//获取小数点的位置
    var count = String(x).length - y;//获取小数点后的个数
    if(y > 0) {
        alert("这个数字是小数,有" + count + "位小数");
    } else {
        alert("不是小数");
    }
</script>

 

//保留n位小数
function roundFun(value, n) {
    return Math.round(value*Math.pow(10,n))/Math.pow(10,n);
}

 

 

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-06
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-09
  • 2021-08-17
  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2021-06-10
相关资源
相似解决方案