summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2018-09-29 17:12:04 +0900
committerEike Rathke <erack@redhat.com>2018-10-15 13:39:30 +0200
commit10fff25227db4d2161dcc3e498654f6bc499a5b2 (patch)
tree4b20b76d5ba57481f4d43295a117ce6235c8d7a3
parente785c027af8d26b78211b0caa740bae7c0384d3a (diff)
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 <erack@redhat.com>
-rw-r--r--sc/qa/unit/data/functions/statistical/fods/skew.fods16
-rw-r--r--sc/qa/unit/data/functions/statistical/fods/skewp.fods16
-rw-r--r--sc/source/core/tool/interpr3.cxx7
3 files changed, 31 insertions, 8 deletions
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;