Bug 156985 - SUM() with mixed formula and value cells may give slightly inaccurate result
Summary: SUM() with mixed formula and value cells may give slightly inaccurate result
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.2.0.4 release
Hardware: All All
: medium normal
Assignee: Eike Rathke
URL:
Whiteboard: target:24.2.0 target:7.6.2 target:7.6...
Keywords:
Depends on:
Blocks:
 
Reported: 2023-08-29 10:46 UTC by Eike Rathke
Modified: 2023-10-16 14:14 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eike Rathke 2023-08-29 10:46:31 UTC
Spin-off of bug 68448.
Using its attachment 84471 [details] observe:

=RAWSUBTRACT(0;A1;A2;A3;A4;A5) gives 2.8421709430404E-14 that is the "raw" subtraction with IEEE 754 double values. The status bar does the same.

=A1+A2+A3+A4+A5 gives 0 as individual operator+ and operator- calculations try to tie the result to 0 if applicable.

=SUM(A1:A5) gives -1.59872115546023E-14 using the Kahan summation algorithm.

The problem here is A1 being the formula =-170.87, replacing that with value -170.87 also =SUM(A1:A5) results in 0.

Apparently since LO 7.2 when Kahan summation was introduced. Which generally gives more accurate results than the previous SUM() algorithm.
Comment 1 Commit Notification 2023-08-31 15:07:34 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/63582b234ddcca3bcb1f76843363e5e7d0b0a08e

Related: tdf#156985 Do not fail for first empty check cell in test failure case

It will be available in 24.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 2 Commit Notification 2023-08-31 16:53:54 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/0603e8fd85f626340c756d80df5612343480beea

Related: tdf#156985 Adjust doc layout to what FunctionsTest::load() expects

It will be available in 24.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 3 Commit Notification 2023-09-01 16:08:02 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/1f8cc7644293e62ad6430bbeec243d3283e478d7

Resolves: tdf#156985 Treat adding two KahanSum differently

It will be available in 24.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 4 Eike Rathke 2023-09-01 16:10:09 UTC
Pending review
https://gerrit.libreoffice.org/c/core/+/156431 for 7-6
https://gerrit.libreoffice.org/c/core/+/156432 for 7-5
Comment 5 Commit Notification 2023-09-04 08:41:20 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

https://git.libreoffice.org/core/commit/1f320173fc92dcf3873751bffe490931542679bc

Resolves: tdf#156985 Treat adding two KahanSum differently

It will be available in 7.6.2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2023-09-04 14:13:07 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/2ac7d339a97efa638124c2862551e0876487833b

tdf#156985: sc_ucalc_formula2: Add unittest

It will be available in 24.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2023-09-06 15:35:52 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-7-6-1":

https://git.libreoffice.org/core/commit/5928323090fa5cd95866b46b91e292aabaddff73

Resolves: tdf#156985 Treat adding two KahanSum differently

It will be available in 7.6.1.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Commit Notification 2023-09-12 07:28:40 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

https://git.libreoffice.org/core/commit/e2397a57ca66a06950a669a3971fbc55b8f5f979

Resolves: tdf#156985 Treat adding two KahanSum differently

It will be available in 7.5.7.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Commit Notification 2023-10-15 16:46:21 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/361c4f008e48b08df635839d2e5dcad7389df44a

Follow-up: tdf#156985 Use SC_USE_SSE2 to determine which KahanSum::add() to use

It will be available in 24.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2023-10-16 09:40:24 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

https://git.libreoffice.org/core/commit/342ba2605f84279f5dd58b8227e73d75e3b9d462

Follow-up: tdf#156985 Use SC_USE_SSE2 to determine which KahanSum::add() to use

It will be available in 7.5.9.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2023-10-16 09:40:27 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

https://git.libreoffice.org/core/commit/d782e07cf1e326cbb26e8a2b4c26be3e48d9fea8

Follow-up: tdf#156985 Use SC_USE_SSE2 to determine which KahanSum::add() to use

It will be available in 7.6.3.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 12 Commit Notification 2023-10-16 12:11:51 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-7-5-8":

https://git.libreoffice.org/core/commit/d9db92481aa8bb98122729acf1d5759e510479d7

Follow-up: tdf#156985 Use SC_USE_SSE2 to determine which KahanSum::add() to use

It will be available in 7.5.8.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.