[Libreoffice-commits] core.git: sc/source

Winfried Donkers winfrieddonkers at libreoffice.org
Wed Oct 5 21:41:09 UTC 2016


 sc/source/core/tool/interpr3.cxx |   22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

New commits:
commit 7ac7968435e556ee23e517a19521eac34ca04296
Author: Winfried Donkers <winfrieddonkers at 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 <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at 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


More information about the Libreoffice-commits mailing list