优化NumberUtil中针对BigDecimal的一些处理逻辑

This commit is contained in:
neko 2020-09-27 17:57:43 +08:00 committed by GitHub
parent 43713aab7d
commit f46a404d9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -440,14 +440,11 @@ public class NumberUtil {
return BigDecimal.ZERO;
}
String value = values[0];
BigDecimal result = null == value ? BigDecimal.ZERO : new BigDecimal(value);
BigDecimal result =new BigDecimal(values[0]);
for (int i = 1; i < values.length; i++) {
value = values[i];
if (null != value) {
result = result.multiply(new BigDecimal(value));
}
result = result.multiply(new BigDecimal(values[i]));
}
return result;
}
@ -464,13 +461,9 @@ public class NumberUtil {
return BigDecimal.ZERO;
}
BigDecimal value = values[0];
BigDecimal result = null == value ? BigDecimal.ZERO : value;
BigDecimal result = values[0];
for (int i = 1; i < values.length; i++) {
value = values[i];
if (null != value) {
result = result.multiply(value);
}
result = result.multiply(values[i]);
}
return result;
}