summaryrefslogtreecommitdiff
path: root/sc/source/core
diff options
context:
space:
mode:
authorWinfried Donkers <winfrieddonkers@libreoffice.org>2016-09-07 17:05:13 +0200
committerEike Rathke <erack@redhat.com>2016-10-05 21:38:49 +0000
commit7ac7968435e556ee23e517a19521eac34ca04296 (patch)
tree888f355188e2589f4207fd925aff0a4fd16af2bd /sc/source/core
parent75d5acfc7820235fab724a63c0bf4e61a0242bec (diff)
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@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/source/core')
-rw-r--r--sc/source/core/tool/interpr3.cxx22
1 files changed, 9 insertions, 13 deletions
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 9dcbbcf5fff8..9b074fa0519f 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