diff options
author | Winfried Donkers <winfrieddonkers@libreoffice.org> | 2017-02-09 17:21:28 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-02-21 21:32:59 +0000 |
commit | 0aca3bde3ae6d1acc241e3aecde5ebca89b75b1b (patch) | |
tree | a7936120aca194acf7ddbd8abaa54d8a265cdc55 | |
parent | ceb1b8f3baa425f0d1ec96ceb2e49e3a04ba4a0a (diff) |
tdf#105885 fix incorrect result with CHISQ.DIST.RT.
With X-argument < 0 Excel returns an error; Calc now does too.
Change-Id: I58a84436b2418bef824b6494c2cc5737932cc936
Reviewed-on: https://gerrit.libreoffice.org/34098
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r-- | sc/source/core/inc/interpre.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/interpr3.cxx | 5 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 4 |
3 files changed, 6 insertions, 5 deletions
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index ccc46ad44e90..bbd18ddd5c17 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -877,7 +877,7 @@ void ScTDist_MS(); void ScTDist_T( int nTails ); void ScFDist(); void ScFDist_LT(); -void ScChiDist(); // for LEGACY.CHIDIST, returns right tail +void ScChiDist( bool bODFF); // for LEGACY.CHIDIST, returns right tail void ScChiSqDist(); // returns left tail or density void ScChiSqDist_MS(); void ScChiSqInv(); //invers to CHISQDIST diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx index 95010d20de62..bef7725393c0 100644 --- a/sc/source/core/tool/interpr3.cxx +++ b/sc/source/core/tool/interpr3.cxx @@ -1729,14 +1729,15 @@ void ScInterpreter::ScFDist_LT() } } -void ScInterpreter::ScChiDist() +void ScInterpreter::ScChiDist( bool bODFF ) { double fResult; if ( !MustHaveParamCount( GetByte(), 2 ) ) return; double fDF = ::rtl::math::approxFloor(GetDouble()); double fChi = GetDouble(); - if (fDF < 1.0) // x<=0 returns 1, see ODFF 6.17.10 + if ( fDF < 1.0 // x<=0 returns 1, see ODFF1.2 6.18.11 + || ( !bODFF && fChi < 0 ) ) // Excel does not accept negative fChi { PushIllegalArgument(); return; diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 09c75f74c7f8..b6e069e3451b 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -4261,8 +4261,8 @@ StackVar ScInterpreter::Interpret() case ocFDist : case ocFDist_RT : ScFDist(); break; case ocFDist_LT : ScFDist_LT(); break; - case ocChiDist : - case ocChiDist_MS : ScChiDist(); break; + case ocChiDist : ScChiDist( true ); break; + case ocChiDist_MS : ScChiDist( false ); break; case ocChiSqDist : ScChiSqDist(); break; case ocChiSqDist_MS : ScChiSqDist_MS(); break; case ocStandard : ScStandard(); break; |