aboutsummaryrefslogtreecommitdiffstats
path: root/poi
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2022-12-15 12:06:39 +0000
committerPJ Fanning <fanningpj@apache.org>2022-12-15 12:06:39 +0000
commit2a34e5a31eead69646f8670b6863ce9d176af1cf (patch)
tree4e99dcfcec8541cb7d6ca8f7c6923f385ed27c0d /poi
parent0d382b4c67549b553db2563ccd030a6c390db5db (diff)
downloadpoi-2a34e5a31eead69646f8670b6863ce9d176af1cf.tar.gz
poi-2a34e5a31eead69646f8670b6863ce9d176af1cf.zip
upgrade mockito and byte-buddy
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1906012 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi')
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/eval/TwoOperandNumericOperation.java14
-rw-r--r--poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumericFunction.java10
2 files changed, 18 insertions, 6 deletions
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/eval/TwoOperandNumericOperation.java b/poi/src/main/java/org/apache/poi/ss/formula/eval/TwoOperandNumericOperation.java
index 0acd9d1871..322ee7b0c5 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/eval/TwoOperandNumericOperation.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/eval/TwoOperandNumericOperation.java
@@ -89,17 +89,19 @@ public abstract class TwoOperandNumericOperation extends Fixed2ArgFunction imple
if (d1 == 0.0) {
throw new EvaluationException(ErrorEval.DIV_ZERO);
}
- BigDecimal bd0 = new BigDecimal(NumberToTextConverter.toText(d0));
- BigDecimal bd1 = new BigDecimal(NumberToTextConverter.toText(d1));
- return bd0.divide(bd1, MathContext.DECIMAL128).doubleValue();
+ BigDecimal bd0 = new BigDecimal(d0);
+ BigDecimal bd1 = new BigDecimal(d1);
+ BigDecimal result = bd0.divide(bd1, MathContext.DECIMAL128);
+ return Double.parseDouble(NumberToTextConverter.toText(result.doubleValue()));
}
};
public static final Function MultiplyEval = new TwoOperandNumericOperation() {
@Override
protected double evaluate(double d0, double d1) {
- BigDecimal bd0 = new BigDecimal(NumberToTextConverter.toText(d0));
- BigDecimal bd1 = new BigDecimal(NumberToTextConverter.toText(d1));
- return bd0.multiply(bd1).doubleValue();
+ BigDecimal bd0 = new BigDecimal(d0);
+ BigDecimal bd1 = new BigDecimal(d1);
+ BigDecimal result = bd0.multiply(bd1);
+ return Double.parseDouble(NumberToTextConverter.toText(result.doubleValue()));
}
};
public static final Function PowerEval = new TwoOperandNumericOperation() {
diff --git a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumericFunction.java b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumericFunction.java
index f398b9217a..c857a7f8ef 100644
--- a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumericFunction.java
+++ b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumericFunction.java
@@ -23,6 +23,7 @@ import org.apache.poi.util.LocaleUtil;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import java.io.IOException;
import java.util.Locale;
import static org.apache.poi.ss.util.Utils.assertDouble;
@@ -45,6 +46,15 @@ final class TestNumericFunction {
}
@Test
+ void testMultiply() throws IOException {
+ 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);
+ }
+ }
+
+ @Test
void testSIGN() {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFCell cell = wb.createSheet().createRow(0).createCell(0);