sc/qa/unit/data/functions/statistical/fods/t.test.fods |    6 +++---
 sc/source/core/tool/interpr3.cxx                       |   10 ++++++++--
 2 files changed, 11 insertions(+), 5 deletions(-)

New commits:
commit 84e87423c182ec78aba4eb108355906a0d2f0096
Author: Winfried Donkers <[email protected]>
Date:   Sun Jan 15 15:14:15 2017 +0100

    tdf#105348 add check for divide by zero situation.
    
    Change-Id: I339997870a7983d829a8909d2b3da7b3ab03f58d
    Reviewed-on: https://gerrit.libreoffice.org/33098
    Tested-by: Jenkins <[email protected]>
    Reviewed-by: Eike Rathke <[email protected]>

diff --git a/sc/qa/unit/data/functions/statistical/fods/t.test.fods 
b/sc/qa/unit/data/functions/statistical/fods/t.test.fods
index 8b2485d..bc3ad19 100644
--- a/sc/qa/unit/data/functions/statistical/fods/t.test.fods
+++ b/sc/qa/unit/data/functions/statistical/fods/t.test.fods
@@ -3803,7 +3803,7 @@
      <table:table-cell table:style-name="ce19" office:value-type="float" 
office:value="0" calcext:value-type="float">
       <text:p>0</text:p>
      </table:table-cell>
-     <table:table-cell table:style-name="ce29" 
table:formula="of:=ROUND([.A2];12)=ROUND([.B2];12)" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+     <table:table-cell table:style-name="ce29" 
table:formula="of:=ISERROR([.A2])" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
       <text:p>TRUE</text:p>
      </table:table-cell>
      <table:table-cell table:style-name="ce32" 
table:formula="of:=FORMULA([.A2])" office:value-type="string" 
office:string-value="=T.TEST(F1:F11,G1:G11,1,1)" calcext:value-type="string">
@@ -4042,7 +4042,7 @@
      <table:table-cell office:value-type="float" office:value="0" 
calcext:value-type="float">
       <text:p>0</text:p>
      </table:table-cell>
-     <table:table-cell table:style-name="ce28" 
table:formula="of:=ROUND([.A6];12)=ROUND([.B6];12)" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+     <table:table-cell table:style-name="ce28" 
table:formula="of:=ISERROR([.A6])" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
       <text:p>TRUE</text:p>
      </table:table-cell>
      <table:table-cell table:style-name="ce32" 
table:formula="of:=FORMULA([.A6])" office:value-type="string" 
office:string-value="=T.TEST(F1:F11,G1:G11,2,1)" calcext:value-type="string">
@@ -6020,4 +6020,4 @@
    </table:named-expressions>
   </office:spreadsheet>
  </office:body>
-</office:document>
\ No newline at end of file
+</office:document>
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 1d90d22..033763f 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -2685,8 +2685,14 @@ void ScInterpreter::ScTTest()
             PushNoValue();
             return;
         }
-        fT = sqrt(fCount-1.0) * fabs(fSum1 - fSum2) /
-             sqrt(fCount * fSumSqrD - (fSum1-fSum2)*(fSum1-fSum2));
+        double fSumD = fSum1 - fSum2;
+        double fDivider = (fCount*fSumSqrD - fSumD*fSumD);
+        if ( fDivider == 0.0 )
+        {
+            PushError(FormulaError::DivisionByZero);
+            return;
+        }
+        fT = fabs(fSumD) * sqrt((fCount-1.0) / fDivider);
         fF = fCount - 1.0;
     }
     else if (fTyp == 2.0)
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to