bigdecimal运算

private double getConsumeRateAB(Long node_consumers, Long node_persons) {
BigDecimal b1 = new BigDecimal(node_consumers);
BigDecimal b2 = new BigDecimal(node_persons);
int len = 2;
boolean flag = (b2.compareTo(BigDecimal.ZERO) != 0) ? true : false;
double doubleRes = 0D;
if (flag){
doubleRes = b1.divide(b2, len, BigDecimal.ROUND_HALF_UP).doubleValue();
}
return doubleRes;
}
posted @ 2020-11-10 19:59  牧の风  阅读(109)  评论(0编辑  收藏  举报