java计算器,没用代码,紧急!! 这两段代码在最后好像没用的,求高人指点下
public static String round(double v, int scale) {
if (scale < 0) {
throw new IllegalArgumentException(
"The scale must be a positive integer or zero");
}
BigDecimal b = new BigDecimal(Double.toString(v));
BigDecimal one = new BigDecimal("1");
return String.valueOf(b.divide(one, scale, BigDecimal.ROUND_HALF_UP));
}
public static String round(String v, int String, int scale) {
if (scale < 0) {
throw new IllegalArgumentException(
"The scale must be a positive integer or zero");
}
BigDecimal b = new BigDecimal(v);
BigDecimal one = new BigDecimal("1");
b.divide(one, scale, BigDecimal.ROUND_HALF_UP);
return null;
} ------解决方案--------------------
这段代码要这么改
public static String round(String v, int string, int scale) {
if (scale < 0) {
throw new IllegalArgumentException(
"The scale must be a positive integer or zero");
}
BigDecimal b = new BigDecimal(v);
BigDecimal one = new BigDecimal(string);
return String.valueOf(b.divide(one, scale, BigDecimal.ROUND_HALF_UP));