Bug 82865 - precision errors in sum()
Summary: precision errors in sum()
Status: CLOSED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.2.6.2 release
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-20 12:03 UTC by abma
Modified: 2014-08-20 13:17 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
Calc - showing Sum error for numbers (10.63 KB, application/vnd.oasis.opendocument.spreadsheet)
2014-08-20 12:04 UTC, abma
Details
same numbers, formated the same, just reordered = different result (25.00 KB, application/vnd.oasis.opendocument.spreadsheet)
2014-08-20 12:47 UTC, abma
Details

Note You need to log in before you can comment on or make changes to this bug.
Description abma 2014-08-20 12:03:11 UTC
rows formated as number gives different results than rows formated as currency:

formated as number
-997,5
-640,36
992,58
997,5
640,36
-992,58
=SUM -1,13686837721616E-013

formated as currency:

-$997,50
-$640,36
$992,58
$997,50
$640,36
-$992,58

=SUM $0,00
Comment 2 abma 2014-08-20 12:04:55 UTC
Created attachment 104976 [details]
Calc - showing Sum error for numbers
Comment 3 Eike Rathke 2014-08-20 12:15:28 UTC
That's normal because the currency format rounds the displayed value to 2 decimals. Calculations do not always result in exact numbers, there may be round-off errors because not all decimal numbers can be exactly represented as binary floating point values.
Comment 4 abma 2014-08-20 12:40:47 UTC
its a sum! there shouldn't be any rounding errors at all!
Comment 5 abma 2014-08-20 12:47:27 UTC
Created attachment 104979 [details]
same numbers, formated the same, just reordered = different result
Comment 6 abma 2014-08-20 12:49:55 UTC
attached a better example. imo summing up numbers should give always the same result, not matter which order they are, also there should be no rounding/precision errors when summing up numbers which are in a small range.
Comment 7 Eike Rathke 2014-08-20 13:17:48 UTC
Please get acquainted with the IEEE 754 floating point format before you try to tell someone that there should be no error. Or read http://support.microsoft.com/default.aspx?scid=kb;EN-US;78113

And yes, summing floating point values does depend on the order the values are encountered.

This is not a bug, this is a limitation in computer hardware and software and the same in most spreadsheet implementations. One can implement magnitude sorted sums and other sorts of tricks to get around the problem to some degree.