赞
踩
自定义四舍五入:
- //自定义四舍五入的的方法
- function round(num,n) {
- num = num * Math.pow(10,n);
- //console.log(num);
- num = Math.round(num);
- //console.log(num);
- num = num * Math.pow(10,-n);
- return num;
- }
- console.log(
- round(345.678,2),
- round(345.678,0),
- round(345.678,-1)
- );
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。