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

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/55152Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
üst 37f6e5de
......@@ -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
......
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