Hallo,
In the ODF 1.2 specification stand , that the GAMMADIST Function only for x < 0 0 returns. The case x > 0 was ok, but there is the special case x == 0. I've tried to implement this.

greetings
Wolfgang
>From 6c45fe24805cf9eba135d3f28b0ddada35806cd5 Mon Sep 17 00:00:00 2001
From: Wolfgang Pechlaner <wope@melmak.(none)>
Date: Mon, 12 Sep 2011 10:52:12 +0200
Subject: [PATCH] 	modified:   sc/source/core/tool/interpr6.cxx

---
 sc/source/core/tool/interpr6.cxx |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index abd6f18..df5a4be 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -152,8 +152,25 @@ double ScInterpreter::GetUpRegIGamma( double fA, double fX )
 double ScInterpreter::GetGammaDistPDF( double fX, double fAlpha, double fLambda )
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetGammaDistPDF" );
-    if (fX <= 0.0)
+    if (fX < 0.0)
         return 0.0;     // see ODFF
+    else if (fX == 0)  
+        // in this case 0^0 isn't zero
+    {
+        if (fAlpha < 1.0)
+        {
+            SetError(errDivisionByZero);  // should be #DIV/0
+            return HUGE_VAL;
+        }
+        else if (fAlpha == 1)
+        {
+            return (1.0 / fLambda);
+        }
+        else
+        {
+            return 0.0;
+        }
+    }       
     else
     {
         double fXr = fX / fLambda;
-- 
1.7.3.4

_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to