目录
- 1 实现
1 实现
代码语言:javascript复制 /**
* @param total 总数
* @param cpnum 各产品数量
* */
public static String getPercentInfo(Double cpnum, Double total){
if (cpnum == null || total == null || total <= 0) {
return "0";
}
double fz = cpnum * 1.0;
double fm = total * 1.0;
double one = fz/fm;
BigDecimal two = new BigDecimal(one);
double three = two.setScale(2,BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100)).doubleValue();
String jtinfo = Double.toString(three) "%";
return jtinfo;
}