sc/inc/kahan.hxx |   11 +++++++++++
 1 file changed, 11 insertions(+)

New commits:
commit 1f8cc7644293e62ad6430bbeec243d3283e478d7
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Fri Sep 1 15:20:28 2023 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Fri Sep 1 18:07:21 2023 +0200

    Resolves: tdf#156985 Treat adding two KahanSum differently
    
    When summing mixed formula cells and numeric cells, cell type runs are
    summed using KahanSum that when switching cell types are added. Using
    add() to explicitly add the rhs m_fError compensation value separately
    may had lead to effectively cancelling out the relation of sum and
    error, living on with an unrelated error value. Instead, add a "final"
    rhs sum+compensation.
    
    Change-Id: I751d3e0eeef9cd80482895c24f05b1ab667c3020
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156253
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <er...@redhat.com>

diff --git a/sc/inc/kahan.hxx b/sc/inc/kahan.hxx
index 6c84f6eeef2e..ac97ae4394fa 100644
--- a/sc/inc/kahan.hxx
+++ b/sc/inc/kahan.hxx
@@ -71,8 +71,15 @@ public:
       */
     inline void add(const KahanSum& fSum)
     {
+#ifdef _WIN32
+        // For some odd unknown reason WIN32 fails badly with the
+        // sum+compensation value. Continue keeping the old though slightly off
+        // (see tdf#156985) explicit addition of the compensation value.
         add(fSum.m_fSum);
         add(fSum.m_fError);
+#else
+        add(fSum.m_fSum + fSum.m_fError);
+#endif
         add(fSum.m_fMem);
     }
 
@@ -82,8 +89,12 @@ public:
       */
     inline void subtract(const KahanSum& fSum)
     {
+#ifdef _WIN32
         add(-fSum.m_fSum);
         add(-fSum.m_fError);
+#else
+        add(-(fSum.m_fSum + fSum.m_fError));
+#endif
         add(-fSum.m_fMem);
     }
 

Reply via email to