Bug 73366 - Error subtraction cells gives incorrect value
Summary: Error subtraction cells gives incorrect value
Status: RESOLVED DUPLICATE of bug 50299
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.1.4.2 release
Hardware: x86-64 (AMD64) macOS (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-07 16:31 UTC by Steve
Modified: 2020-10-11 17:56 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Example of calclation that is incorrect when referncing other formulas (7.70 KB, application/vnd.oasis.opendocument.spreadsheet)
2014-01-07 16:31 UTC, Steve
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steve 2014-01-07 16:31:18 UTC
Created attachment 91607 [details]
Example of calclation that is incorrect when referncing other formulas

Attached is an example of a sheet where formulas to column G should all be 0.  The one the G3 gives -2.501E-012.

F4 = 509.78

H4 = 1108.8
I4 = 1.18
J4 = 10500

K4 = H4 + I4 - J4 = 509.78 (correct)

G4 = F4 - K4 = 509.78 - 509.78 = -2.501E-02 (incorrect, should be 0).

Cheers,
Steve
Comment 1 Steve 2014-01-07 16:38:38 UTC
Comment on attachment 91607 [details]
Example of calclation that is incorrect when referncing other formulas

Corrected mimetype
Comment 2 Steve 2014-01-07 17:19:15 UTC
Saving, closing, and reopening the attachment seems to give the correct answer, but reconstructing from scratch each time shows the problem.  Also the problem stays in my accounts spreadsheet, even after reopening.

Steve
Comment 3 Steve 2014-01-07 17:49:42 UTC
I have upgrade to LO 4.1.4.2 and the problem still exists.  FYI I'm using the English GB Language version.
Comment 4 Steve 2014-01-07 17:58:00 UTC
A quick fix is to use the Round function, so somewhere precision is getting lost.

e.g. Round(H4 + I4 - J4, 2) give 0.00

Steve
Comment 5 m_a_riosv 2014-01-08 01:01:00 UTC
Hi Steve,

I think the issue is in relation with the computations precision, please take a look to this links:
https://bugs.freedesktop.org/show_bug.cgi?id=50299
http://ask.libreoffice.org/en/question/8006/libreoffice-calc-calculation-error/

As not all number have an exact representation in binary format, maybe the subtraction result.

I think there is no solution, the best approximation, take care of it when designing the spreadsheet. Otherwise using a specialised software.

To don't lose precision with rounding, I think rounding at doubled decimals of needed precision could be enough.

*** This bug has been marked as a duplicate of bug 50299 ***
Comment 6 b. 2020-10-11 17:56:13 UTC
as of today i cannot find an error in the sheet, 

but in that calculation, it doesn't hold in any respect ... 

H4 = 1108.8
I4 = 1.18
J4 = 10500

K4 = H4 + I4 - J4 = 509.78 (correct)

what doesn't mean fp-calculations are correct in calc or 'best possible', just this sample fails in itself ...