summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2018-06-01 12:40:11 +0900
committerEike Rathke <erack@redhat.com>2018-06-11 13:00:42 +0200
commitd17e8faa13b1f8d943b602aa6ea754c1b22fdd76 (patch)
treeb02d6989a87bc88c25f6abce0466ca1f35c7448d /sc
parent37f6e5de1e72d209b0892734f4de5c4d8a849885 (diff)
sc: Make ZTEST() raise #DIV/0! when the sample stddev is 0
because it is an actual division-by-zero error and Excel does. Call for suggestion: I would like to add a test case to sc/qa/unit/data/functions/statistical/fods/ztest.fods, but do not know the right manner of adding it cleanly without messing up other parts such as styles. Change-Id: I79b99a6b7385177e94d75bb4e00d724332b9b8bf Reviewed-on: https://gerrit.libreoffice.org/55152 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/tool/interpr3.cxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index a43ec7835193..8c433bab587c 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -2560,6 +2560,11 @@ void ScInterpreter::ScZTest()
if (nParamCount != 3)
{
sigma = (fSumSqr - fSum*fSum/rValCount)/(rValCount-1.0);
+ if (sigma == 0.0)
+ {
+ PushError(FormulaError::DivisionByZero);
+ return;
+ }
PushDouble(0.5 - gauss((mue-x)/sqrt(sigma/rValCount)));
}
else