sc/qa/unit/data/functions/statistical/fods/skew.fods  |   16 ++++++++++++----
 sc/qa/unit/data/functions/statistical/fods/skewp.fods |   16 ++++++++++++----
 sc/source/core/tool/interpr3.cxx                      |    7 +++++++
 3 files changed, 31 insertions(+), 8 deletions(-)

New commits:
commit 10fff25227db4d2161dcc3e498654f6bc499a5b2
Author:     Takeshi Abe <t...@fixedpoint.jp>
AuthorDate: Sat Sep 29 17:12:04 2018 +0900
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Mon Oct 15 13:39:30 2018 +0200

    sc: Let SKEW/SKEWP raise #!DIV/0 when < 3 numbers are given
    
    as ODF 1.2 mentions such constaints of these functions, and
    Excel's documentation also admits it with more specific remark:
    
<https://support.office.com/en-us/article/skew-function-bdf49d86-b1ef-4804-a046-28eaea69c9fa>
    
<https://support.office.com/en-us/article/skew-p-function-76530a5c-99b9-48a1-8392-26632d542fcb>
    
    Change-Id: If19350997ddcb6f0fb36e29e090e260c3ae3d262
    Reviewed-on: https://gerrit.libreoffice.org/61130
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <er...@redhat.com>

diff --git a/sc/qa/unit/data/functions/statistical/fods/skew.fods 
b/sc/qa/unit/data/functions/statistical/fods/skew.fods
index eb778fd7b4c8..d33270cc7058 100644
--- a/sc/qa/unit/data/functions/statistical/fods/skew.fods
+++ b/sc/qa/unit/data/functions/statistical/fods/skew.fods
@@ -5047,10 +5047,18 @@
      <table:table-cell table:number-columns-repeated="2"/>
     </table:table-row>
     <table:table-row table:style-name="ro6">
-     <table:table-cell table:style-name="ce27"/>
-     <table:table-cell/>
-     <table:table-cell table:style-name="ce28"/>
-     <table:table-cell table:style-name="ce32"/>
+     <table:table-cell table:style-name="ce27" table:formula="of:=SKEW(1;2)" 
office:value-type="string" office:string-value="" calcext:value-type="error">
+      <text:p>#DIV/0!</text:p>
+     </table:table-cell>
+     <table:table-cell table:formula="of:#DIV/0!" office:value-type="string" 
office:string-value="" calcext:value-type="error">
+      <text:p>#DIV/0!</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce28" 
table:formula="of:=ERROR.TYPE([.A32])=2" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce32" 
table:formula="of:=FORMULA([.A32])" office:value-type="string" 
office:string-value="=SKEW(1,2)" calcext:value-type="string">
+      <text:p>=SKEW(1,2)</text:p>
+     </table:table-cell>
      <table:table-cell table:number-columns-repeated="4"/>
      <table:table-cell office:value-type="float" office:value="900000031" 
calcext:value-type="float">
       <text:p>900000031</text:p>
diff --git a/sc/qa/unit/data/functions/statistical/fods/skewp.fods 
b/sc/qa/unit/data/functions/statistical/fods/skewp.fods
index 07795c6009c0..57017c6fb09c 100644
--- a/sc/qa/unit/data/functions/statistical/fods/skewp.fods
+++ b/sc/qa/unit/data/functions/statistical/fods/skewp.fods
@@ -5041,10 +5041,18 @@
      <table:table-cell table:number-columns-repeated="2"/>
     </table:table-row>
     <table:table-row table:style-name="ro6">
-     <table:table-cell table:style-name="ce27"/>
-     <table:table-cell/>
-     <table:table-cell table:style-name="ce28"/>
-     <table:table-cell table:style-name="ce32"/>
+     <table:table-cell table:style-name="ce27" table:formula="of:=SKEWP(1;2)" 
office:value-type="string" office:string-value="" calcext:value-type="error">
+      <text:p>#DIV/0!</text:p>
+     </table:table-cell>
+     <table:table-cell table:formula="of:#DIV/0!" office:value-type="string" 
office:string-value="" calcext:value-type="error">
+      <text:p>#DIV/0!</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce28" 
table:formula="of:=ERROR.TYPE([.A32])=2" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce32" 
table:formula="of:=FORMULA([.A32])" office:value-type="string" 
office:string-value="=SKEWP(1,2)" calcext:value-type="string">
+      <text:p>=SKEWP(1,2)</text:p>
+     </table:table-cell>
      <table:table-cell table:number-columns-repeated="4"/>
      <table:table-cell office:value-type="float" office:value="900000031" 
calcext:value-type="float">
       <text:p>900000031</text:p>
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index ed2dc48f8f7c..2b117b2be56c 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -3323,6 +3323,13 @@ void ScInterpreter::CalculateSkewOrSkewp( bool bSkewp )
     std::vector<double> values;
     if (!CalculateSkew( fSum, fCount, vSum, values))
         return;
+     // SKEW/SKEWP's constraints: they require at least three numbers
+    if (fCount < 3.0)
+    {
+        // for interoperability with Excel
+        PushError(FormulaError::DivisionByZero);
+        return;
+    }
 
     double fMean = fSum / fCount;
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to