diff options
Diffstat (limited to 'scaddins/source/analysis/analysishelper.cxx')
-rw-r--r-- | scaddins/source/analysis/analysishelper.cxx | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx index 6b4309a6f3c7..56064b56f884 100644 --- a/scaddins/source/analysis/analysishelper.cxx +++ b/scaddins/source/analysis/analysishelper.cxx @@ -521,29 +521,32 @@ double GetYearFrac( sal_Int32 nNullDate, sal_Int32 nStartDate, sal_Int32 nEndDat return double( nYears ) + double( nDayDiff ) / double( nDaysInYear ); } - -double Fak( sal_Int32 n ) +double BinomialCoefficient( double n, double k ) { - if( n > 0 ) - { - double fRet = n; - double f = n - 1; + // This method is a copy of BinomKoeff() + // found in sc/source/core/tool/interpr3.cxx - while( f >= 2.0 ) + double nVal = 0.0; + k = ::rtl::math::approxFloor(k); + if (n < k) + nVal = 0.0; + else if (k == 0.0) + nVal = 1.0; + else + { + nVal = n/k; + n--; + k--; + while (k > 0.0) { - fRet *= f; - f--; + nVal *= n/k; + k--; + n--; } - - return fRet; } - else if( !n ) - return 1.0; - else - return 0.0; + return nVal; } - double GetGcd( double f1, double f2 ) { double f = fmod( f1, f2 ); |