aboutsummaryrefslogtreecommitdiffstats
path: root/poi/src
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2022-02-03 10:05:38 +0000
committerPJ Fanning <fanningpj@apache.org>2022-02-03 10:05:38 +0000
commit9a97204dc8cd4613f43480359243221bdecfe15e (patch)
treef7ad9052369612f088dc87af4cd4c8d079b49c92 /poi/src
parent3a1fb48124021d0e66a76996905957a6dd9528e5 (diff)
downloadpoi-9a97204dc8cd4613f43480359243221bdecfe15e.tar.gz
poi-9a97204dc8cd4613f43480359243221bdecfe15e.zip
add INT tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1897715 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi/src')
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/NumericFunction.java1
-rw-r--r--poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumericFunction.java10
2 files changed, 8 insertions, 3 deletions
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/NumericFunction.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/NumericFunction.java
index 1ba040e4da..557fbc7893 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/NumericFunction.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/NumericFunction.java
@@ -100,6 +100,7 @@ public abstract class NumericFunction implements Function {
public static final Function EXP = oneDouble(d -> Math.pow(Math.E, d));
public static final Function FACT = oneDouble(MathX::factorial);
+ //https://support.microsoft.com/en-us/office/int-function-a6c4af9e-356d-4369-ab6a-cb1fd9d343ef
public static final Function INT = oneDouble(d -> Math.round(d-0.5));
public static final Function LN = oneDouble(Math::log);
public static final Function LOG10 = oneDouble(d -> Math.log(d) / LOG_10_TO_BASE_e);
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 bdb75f027f..77d204aeff 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
@@ -30,8 +30,12 @@ final class TestNumericFunction {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFCell cell = wb.createSheet().createRow(0).createCell(0);
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
- assertDouble(fe, cell, "880000000*0.00849", 7471200.0, 0.00000001);
- assertDouble(fe, cell, "880000000*0.00849/3", 2490400.0, 0.00000001);
- assertDouble(fe, cell, "INT(880000000*0.00849/3)", 2490400.0, 0.00000001);
+ assertDouble(fe, cell, "INT(880000000.0001)", 880000000.0, 0);
+ //the following INT(-880000000.0001) resulting in -880000001.0 has been observed in excel
+ //see also https://support.microsoft.com/en-us/office/int-function-a6c4af9e-356d-4369-ab6a-cb1fd9d343ef
+ assertDouble(fe, cell, "INT(-880000000.0001)", -880000001.0, 0);
+ assertDouble(fe, cell, "880000000*0.00849", 7471200.0, 0);
+ assertDouble(fe, cell, "880000000*0.00849/3", 2490400.0, 0);
+ assertDouble(fe, cell, "INT(880000000*0.00849/3)", 2490400.0, 0);
}
}