Bug 122524 - EDITING :: Wrong calculation results, depends on the order of items
Summary: EDITING :: Wrong calculation results, depends on the order of items
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
6.1.4.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-07 08:29 UTC by Zirneklītis
Modified: 2019-01-07 08:41 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
The Calc spreadsheet with the given example (8.52 KB, application/vnd.oasis.opendocument.spreadsheet)
2019-01-07 08:29 UTC, Zirneklītis
Details
A screen-shot with buggy calculation (7.72 KB, image/png)
2019-01-07 08:30 UTC, Zirneklītis
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zirneklītis 2019-01-07 08:29:15 UTC
Created attachment 148086 [details]
The Calc spreadsheet with the given example

The following equation gives a wrong result:
100 - 1.4 - 95.9 - 2.7 =  -1,15463194561016E-14

Should be: 0


If the item order is changed, the calculated result is correct:

100 - 95,9 - 1,4 - 2,7 = 0.

The tested versions:

Fedora 23 / LibreOffice 5.3.2.1 30(Build:1) x64

Fedora 28 / LibreOffice 6.0.7.3.0 00(Build:3) x64

Windows 10 / LibreOffice 6.1.4.2 (Build ID: 9d0f32d1f0b509096fd65e0d4bec26ddd1938fd3) x64
Comment 1 Zirneklītis 2019-01-07 08:30:46 UTC
Created attachment 148087 [details]
A screen-shot with buggy calculation
Comment 2 Mike Kaganski 2019-01-07 08:41:35 UTC
This is not a bug, but the result of non-representability of some numbers in computer [1]. Using computer-aided computations, user must be prepared for such things, unfortunately because they are simply unavoidable. It's normal than changing the order of calculations, you get different intermediate results, which may happen to be representable in IEEE 754 form, or may simply happen to be represented closer to ideal values.

[1] https://en.wikipedia.org/wiki/Floating-point_arithmetic#Accuracy_problems