67,512
社区成员
发帖
与我相关
我的任务
分享
//计算总金额
it = null;
Double countfree=0.0;
it = list2.iterator();
while (it.hasNext()) {
Object[] obj = (Object[]) it.next();
obj[31] = obj[31]==null ? 0.0 : obj[31];
countfree += Double.valueOf(obj[31].toString());
}
DecimalFormat df = new DecimalFormat("0.00");
String num = df.format(countfree);
public static BigDecimal add(String s1,String s2){
BigDecimal d1 = new BigDecimal(s1);
BigDecimal d2 = new BigDecimal(s2);
return d1.add(d2);
}
//计算总金额
it = null;;
countfree=0.0;
it = list2.iterator();
while (it.hasNext()) {
Object[] obj = (Object[]) it.next();
obj[31] = obj[31]==null ? 0 : obj[31];
countfree = Util.add(Double.parseDouble(obj[31].toString()), countfree);
//countfree += Double.parseDouble(obj[31].toString());
}
DecimalFormat df = new DecimalFormat("0.00");
String num = df.format(countfree);
public static double add(double v1, double v2) {
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.add(b2).doubleValue();
}
通过Bigdecimal累加后还是不行