Cirry's Blog

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

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