revert accidental change to multiply/divide

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1906013 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2022-12-15 12:10:02 +00:00
parent 2a34e5a31e
commit 7e2f2bbbfb
2 changed files with 7 additions and 9 deletions

View File

@ -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() {

View File

@ -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);
}
}