4去5入到指定位数

    技术2022-05-20  43

    function my_round(num, how){   if (isNaN(num))   {      return 'N/A';   }      if (isNaN(how)) return num;   if (how < 1) return Math.round(num);      var splits = num.toString(10).split(".");   if ( (splits.length != 2) || (splits[1].length < (how + 1)))   {     return num;   }   else   {      how = Math.pow(10,how);      return Math.round(num * how )/how ;   }}


    最新回复(0)