Cirry's Blog

java实现四舍五入且指定小数位数

2019-10-09
技术 java
1分钟
38字
1
package cn.cccc.demo;
2
class MathUtil{
3
private MathUtil(){};
4
5
public static double round(double num, int scale){
6
return Math.round(num * Math.pow(10, scale)) / Math.pow(10, scale);
7
}
8
}
9
public class ThreadDemo {
10
public static void main(String[] args) throws Exception{
11
System.out.println(MathUtil.round(19.46735, 2));
12
}
13
}
本文标题:java实现四舍五入且指定小数位数
文章作者:Cirry
发布时间:2019-10-09
感谢大佬送来的咖啡☕
alipayQRCode
wechatQRCode
总访问量
总访客数人次