济菏高速数据中心代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

18 lines
474 B

package com.zc.business.utils;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class MathUtil {
/**
* 保留两位小数
* @param d 数字
* @return 保留两位小数后的数字
*/
public static double doubleTwoDecimal(double d){
BigDecimal originalNumber = new BigDecimal(d);
BigDecimal roundedNumber = originalNumber.setScale(2, RoundingMode.HALF_UP);
return roundedNumber.doubleValue();
}
}