summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2023-09-01 15:20:28 +0200
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2023-09-06 17:34:53 +0200
commit5928323090fa5cd95866b46b91e292aabaddff73 (patch)
treec6179915ac3ec73ba856dcf11b758829dd65034a
parent281dd7b2c0f42f8edbbc7bdeadbdd0c44dc44bd0 (diff)
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 <erack@redhat.com> (cherry picked from commit caafee1a4805e40d29be5c90f3a021ed6ef5c4d2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156431 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> (cherry picked from commit 3cb3b713e1f3b8abe8d9bb46c89f58c7efdf8196) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156444 Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org> Reviewed-by: Hossein <hossein@libreoffice.org> Tested-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r--sc/inc/kahan.hxx11
1 files changed, 11 insertions, 0 deletions
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);
}