Kaydet (Commit) 10fff252 authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Eike Rathke

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: 's avatarEike Rathke <erack@redhat.com>
üst e785c027
......@@ -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>
......
......@@ -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>
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment