瀏覽代碼

revert accidental change to multiply/divide

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1906013 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_5_2_4
PJ Fanning 1 年之前
父節點
當前提交
7e2f2bbbfb

+ 6
- 8
poi/src/main/java/org/apache/poi/ss/formula/eval/TwoOperandNumericOperation.java 查看文件

@@ -89,19 +89,17 @@ public abstract class TwoOperandNumericOperation extends Fixed2ArgFunction imple
if (d1 == 0.0) {
throw new EvaluationException(ErrorEval.DIV_ZERO);
}
BigDecimal bd0 = new BigDecimal(d0);
BigDecimal bd1 = new BigDecimal(d1);
BigDecimal result = bd0.divide(bd1, MathContext.DECIMAL128);
return Double.parseDouble(NumberToTextConverter.toText(result.doubleValue()));
BigDecimal bd0 = new BigDecimal(NumberToTextConverter.toText(d0));
BigDecimal bd1 = new BigDecimal(NumberToTextConverter.toText(d1));
return bd0.divide(bd1, MathContext.DECIMAL128).doubleValue();
}
};
public static final Function MultiplyEval = new TwoOperandNumericOperation() {
@Override
protected double evaluate(double d0, double d1) {
BigDecimal bd0 = new BigDecimal(d0);
BigDecimal bd1 = new BigDecimal(d1);
BigDecimal result = bd0.multiply(bd1);
return Double.parseDouble(NumberToTextConverter.toText(result.doubleValue()));
BigDecimal bd0 = new BigDecimal(NumberToTextConverter.toText(d0));
BigDecimal bd1 = new BigDecimal(NumberToTextConverter.toText(d1));
return bd0.multiply(bd1).doubleValue();
}
};
public static final Function PowerEval = new TwoOperandNumericOperation() {

+ 1
- 1
poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumericFunction.java 查看文件

@@ -50,7 +50,7 @@ final class TestNumericFunction {
try (HSSFWorkbook wb = new HSSFWorkbook()) {
HSSFCell cell = wb.createSheet().createRow(0).createCell(0);
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
assertDouble(fe, cell, "1.2*SQRT(5.678)", 2.85942651592937, 0);
assertDouble(fe, cell, "1.2*SQRT(5.678)", 2.85942651592938, 0);
}
}


Loading…
取消
儲存