var PI = 1213.141592653; // 常量大写 console.log(PI.toFixed(2)); console.log(parseInt(PI * 100) / 100); var str = PI + ""; // 因为数字没法进行字符操作 先转换 console.log(str.substr(0, str.indexOf(".") + 3));
保留小数点后几位的三种方法
猜你喜欢
转载自www.cnblogs.com/ustc-yy/p/12094965.html
今日推荐
周排行