]> source.dussan.org Git - poi.git/commitdiff
add INT tests
authorPJ Fanning <fanningpj@apache.org>
Thu, 3 Feb 2022 10:05:38 +0000 (10:05 +0000)
committerPJ Fanning <fanningpj@apache.org>
Thu, 3 Feb 2022 10:05:38 +0000 (10:05 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1897715 13f79535-47bb-0310-9956-ffa450edef68

poi/src/main/java/org/apache/poi/ss/formula/functions/NumericFunction.java
poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumericFunction.java

index 1ba040e4da86156bf33910b285b1a78a4ba72894..557fbc789399642a6527e30dd3bd56e5ec5c5ba4 100644 (file)
@@ -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);
index bdb75f027f78e9fe1fc73fced38807767154f7cd..77d204aeff53a73ca0bb545c1e3ceae0d1bb6a17 100644 (file)
@@ -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);
     }
 }