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

Winfried Donkers winfrieddonkers at libreoffice.org
Fri Sep 16 15:43:44 UTC 2016


 sc/source/core/tool/interpr3.cxx |   25 +++++--------------------
 1 file changed, 5 insertions(+), 20 deletions(-)

New commits:
commit 46f09cb1252078ef23ed93a3551acbdcca9d31cd
Author: Winfried Donkers <winfrieddonkers at libreoffice.org>
Date:   Fri Sep 2 11:03:11 2016 +0200

    tdf#101855 BETA.DIST: apply same constraints as Excel does.
    
    Change-Id: I617146665e72286aef3de35b859ca2e52d039bd8
    Reviewed-on: https://gerrit.libreoffice.org/28612
    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 9a89993..5d51bad 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -1079,10 +1079,10 @@ void ScInterpreter::ScBetaDist()
 }
 
 /**
-  fdo#71008
   Microsoft version has parameters in different order
   Also, upper and lowerbound are optional and have default values
-  otherwise, function is identical with ScInterpreter::ScBetaDist()
+  and different constraints apply.
+  Basically, function is identical with ScInterpreter::ScBetaDist()
 */
 void ScInterpreter::ScBetaDist_MS()
 {
@@ -1096,7 +1096,7 @@ void ScInterpreter::ScBetaDist_MS()
         fUpperBound = GetDouble();
     else
         fUpperBound = 1.0;
-    if (nParamCount >= 4)
+    if (nParamCount >= 5)
         fLowerBound = GetDouble();
     else
         fLowerBound = 0.0;
@@ -1104,35 +1104,20 @@ void ScInterpreter::ScBetaDist_MS()
     beta = GetDouble();
     alpha = GetDouble();
     x = GetDouble();
-    double fScale = fUpperBound - fLowerBound;
-    if (fScale <= 0.0 || alpha <= 0.0 || beta <= 0.0)
+    if (alpha <= 0.0 || beta <= 0.0 || x < fLowerBound || x > fUpperBound)
     {
         PushIllegalArgument();
         return;
     }
+    double fScale = fUpperBound - fLowerBound;
     if (bIsCumulative) // cumulative distribution function
     {
-        // special cases
-        if (x < fLowerBound)
-        {
-            PushDouble(0.0); return; //see spec
-        }
-        if (x > fUpperBound)
-        {
-            PushDouble(1.0); return; //see spec
-        }
-        // normal cases
         x = (x-fLowerBound)/fScale;  // convert to standard form
         PushDouble(GetBetaDist(x, alpha, beta));
         return;
     }
     else // probability density function
     {
-        if (x < fLowerBound || x > fUpperBound)
-        {
-            PushDouble(0.0);
-            return;
-        }
         x = (x-fLowerBound)/fScale;
         PushDouble(GetBetaDistPDF(x, alpha, beta)/fScale);
         return;


More information about the Libreoffice-commits mailing list