|
@@ -25,10 +25,10 @@ public class ComputeFormulaUtil {
|
|
|
|
|
|
public BigDecimal getResult() {
|
|
|
BigDecimal nextValue = nextValue(BigDecimal.ZERO, '+');
|
|
|
- if(val!=null&&val[0]=='['&&val[len-1]==']'){
|
|
|
- return new BigDecimal(0.0-nextValue.doubleValue());
|
|
|
+ if (val != null && val[0] == '[' && val[len - 1] == ']') {
|
|
|
+ return nextValue.abs();
|
|
|
}
|
|
|
- return nextValue(BigDecimal.ZERO, '+');
|
|
|
+ return nextValue;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -108,9 +108,8 @@ public class ComputeFormulaUtil {
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
- ComputeFormulaUtil computeUtil = new ComputeFormulaUtil("[0-1]");
|
|
|
+ ComputeFormulaUtil computeUtil = new ComputeFormulaUtil("106.61");
|
|
|
BigDecimal result = computeUtil.getResult();
|
|
|
System.out.println(result);
|
|
|
}
|
|
|
-
|
|
|
}
|