summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorWinfried Donkers <winfrieddonkers@libreoffice.org>2017-01-15 15:14:15 +0100
committerEike Rathke <erack@redhat.com>2017-01-23 16:26:16 +0000
commit84e87423c182ec78aba4eb108355906a0d2f0096 (patch)
treeaf806e411c57ca03a8ee83a887ed21b2570ee9fa /sc
parentabc8057ab1a1189ff7f88d42b13b363ceb228d16 (diff)
tdf#105348 add check for divide by zero situation.
Change-Id: I339997870a7983d829a8909d2b3da7b3ab03f58d Reviewed-on: https://gerrit.libreoffice.org/33098 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/data/functions/statistical/fods/t.test.fods6
-rw-r--r--sc/source/core/tool/interpr3.cxx10
2 files changed, 11 insertions, 5 deletions
diff --git a/sc/qa/unit/data/functions/statistical/fods/t.test.fods b/sc/qa/unit/data/functions/statistical/fods/t.test.fods
index 8b2485defa01..bc3ad19ca295 100644
--- a/sc/qa/unit/data/functions/statistical/fods/t.test.fods
+++ b/sc/qa/unit/data/functions/statistical/fods/t.test.fods
@@ -3803,7 +3803,7 @@
<table:table-cell table:style-name="ce19" office:value-type="float" office:value="0" calcext:value-type="float">
<text:p>0</text:p>
</table:table-cell>
- <table:table-cell table:style-name="ce29" table:formula="of:=ROUND([.A2];12)=ROUND([.B2];12)" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean">
+ <table:table-cell table:style-name="ce29" table:formula="of:=ISERROR([.A2])" 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([.A2])" office:value-type="string" office:string-value="=T.TEST(F1:F11,G1:G11,1,1)" calcext:value-type="string">
@@ -4042,7 +4042,7 @@
<table:table-cell office:value-type="float" office:value="0" calcext:value-type="float">
<text:p>0</text:p>
</table:table-cell>
- <table:table-cell table:style-name="ce28" table:formula="of:=ROUND([.A6];12)=ROUND([.B6];12)" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean">
+ <table:table-cell table:style-name="ce28" table:formula="of:=ISERROR([.A6])" 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([.A6])" office:value-type="string" office:string-value="=T.TEST(F1:F11,G1:G11,2,1)" calcext:value-type="string">
@@ -6020,4 +6020,4 @@
</table:named-expressions>
</office:spreadsheet>
</office:body>
-</office:document> \ No newline at end of file
+</office:document>
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 1d90d22b4b3a..033763f5c6a7 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -2685,8 +2685,14 @@ void ScInterpreter::ScTTest()
PushNoValue();
return;
}
- fT = sqrt(fCount-1.0) * fabs(fSum1 - fSum2) /
- sqrt(fCount * fSumSqrD - (fSum1-fSum2)*(fSum1-fSum2));
+ double fSumD = fSum1 - fSum2;
+ double fDivider = (fCount*fSumSqrD - fSumD*fSumD);
+ if ( fDivider == 0.0 )
+ {
+ PushError(FormulaError::DivisionByZero);
+ return;
+ }
+ fT = fabs(fSumD) * sqrt((fCount-1.0) / fDivider);
fF = fCount - 1.0;
}
else if (fTyp == 2.0)