Bug 87875 - Substraction does yield zero
Summary: Substraction does yield zero
Status: RESOLVED DUPLICATE of bug 81971
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: x86 (IA32) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-30 21:23 UTC by cerien
Modified: 2015-04-29 17:37 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
sample simple spreadsheet showing defect (13.26 KB, application/vnd.oasis.opendocument.spreadsheet)
2014-12-30 21:23 UTC, cerien
Details
second try (13.26 KB, application/vnd.oasis.opendocument.spreadsheet)
2014-12-30 23:07 UTC, cerien
Details

Note You need to log in before you can comment on or make changes to this bug.
Description cerien 2014-12-30 21:23:10 UTC
Created attachment 111538 [details]
sample simple spreadsheet showing defect

Hello

I am substracting two values in a simple blank spreadsheet:
B4=2688,21
C4=2685,92
D4=2,29

E4: =B4-C4-D4

E4 shows -4,91162666094169E-013 , and not 0 !!!!

All figures are constant, and not calc results, so I fail to see any explanation

see attached sheet 

Calc version: 
Version: 4.2.8.2
Build ID: 48d50dbfc06349262c9d50868e5c1f630a573ebd
Comment 1 Tim Lloyd 2014-12-30 22:44:42 UTC
Hi cerien,

I could not open the file however your instructions produced the same response for me but I have a solution!

After recreating the problem I simply formatted each cell to be a number with 2 decimal places and voila, problem solved. Can you advise whether this works for you?

I will also note that entering numbers without decimal places does not cause this problem.

I'll set to needinfo and maybe one of our learned friends can advise whether calc should recognise  the decimal places?

Cheers
Comment 2 Tim Lloyd 2014-12-30 22:52:08 UTC
BTW testing with 4.3.3.2 on Fedora

and

Version: 4.5.0.0.alpha0+
Build ID: ebfec3517d001f8aa8baaabde7c4af6b01347b95
TinderBox: Linux-rpm_deb-x86_64@46-TDF, Branch:master, Time: 2014-12-06_00:52:12
Locale: en_AU
Comment 3 cerien 2014-12-30 23:07:35 UTC
Created attachment 111542 [details]
second try
Comment 4 cerien 2014-12-30 23:11:47 UTC
Hi

I'm glad you could reproduce it. I've reuploaded the file.

Rounding/formatting to remove 10e-x decimals is just a mere workaround, as the key problem remains a wrong calculation !!!

I fail to accept that substracting two two-decimal figures can yield to some far away decimals remainder....

I've also opened the spreadsheet on a 4.1.5.3 on Win 8, and same problem !

Rgds
Comment 5 A (Andy) 2014-12-30 23:14:32 UTC
This issue is reproducible with LO 4.4.0.0.beta1, but it was already discussed in other bug reports in the past.  I mark it therefore as a duplicate.  See also the bugs mentioned in the See Also section of this Bugzilla report.
It is a technial floating point issue.  Unfortunately, I don't know if there will an (easy) solution for the normal user in the future.

*** This bug has been marked as a duplicate of bug 81971 ***