sc/source/core/tool/interpr3.cxx | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
New commits: commit 7ac7968435e556ee23e517a19521eac34ca04296 Author: Winfried Donkers <winfrieddonk...@libreoffice.org> Date: Wed Sep 7 17:05:13 2016 +0200 tdf#101943 Make Calc functions BETAINV and BETA.INV comply with ODFF1.2 (and with Excel where not contradictory with ODFF) and fix wrong result for probability 0. Excel does not allow a probability of 0, where ODFF does. A probability of 0 is mathematically correct and BETADIST( a, alpha, beta, b ) returns 0 both in Calc and Excel. Change-Id: I06c758c307584420aaccc1a97a35196af14d54f4 Reviewed-on: https://gerrit.libreoffice.org/28723 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Eike Rathke <er...@redhat.com> diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx index 9dcbbcf..9b074fa 100644 --- a/sc/source/core/tool/interpr3.cxx +++ b/sc/source/core/tool/interpr3.cxx @@ -2243,24 +2243,20 @@ void ScInterpreter::ScBetaInv() fBeta = GetDouble(); fAlpha = GetDouble(); fP = GetDouble(); - if (fP < 0.0 || fP >= 1.0 || fA == fB || fAlpha <= 0.0 || fBeta <= 0.0) + if (fP < 0.0 || fP > 1.0 || fA >= fB || fAlpha <= 0.0 || fBeta <= 0.0) { PushIllegalArgument(); return; } - if (fP == 0.0) - PushInt(0); + + bool bConvError; + ScBetaDistFunction aFunc( *this, fP, fAlpha, fBeta ); + // 0..1 as range for iteration so it isn't extended beyond the valid range + double fVal = lcl_IterateInverse( aFunc, 0.0, 1.0, bConvError ); + if (bConvError) + PushError( FormulaError::NoConvergence); else - { - bool bConvError; - ScBetaDistFunction aFunc( *this, fP, fAlpha, fBeta ); - // 0..1 as range for iteration so it isn't extended beyond the valid range - double fVal = lcl_IterateInverse( aFunc, 0.0, 1.0, bConvError ); - if (bConvError) - PushError( FormulaError::NoConvergence); - else - PushDouble(fA + fVal*(fB-fA)); // scale to (A,B) - } + PushDouble(fA + fVal*(fB-fA)); // scale to (A,B) } // Achtung: T, F und Chi _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits