After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 662938 - Bad calculation
Bad calculation
Status: RESOLVED DUPLICATE of bug 613557
Product: Gnumeric
Classification: Applications
Component: General
unspecified
Other Windows
: Normal normal
: ---
Assigned To: Jody Goldberg
Jody Goldberg
Depends on:
Blocks:
 
 
Reported: 2011-10-28 14:14 UTC by klese176
Modified: 2011-10-28 19:44 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description klese176 2011-10-28 14:14:54 UTC
Type the following in any cell

0,05
-0,07
0,02
0

Do a sum of the above cells gives
-3,46944695195361E-018

instead of 0

Same bug in Excel but not in calc
Comment 1 Morten Welinder 2011-10-28 16:33:46 UTC

*** This bug has been marked as a duplicate of bug 613557 ***
Comment 2 Andreas J. Guelzow 2011-10-28 16:34:57 UTC
One should probably note that this is not a bug. The explanation for this is in the duplicate "bug" report.
Comment 3 Andreas J. Guelzow 2011-10-28 16:37:20 UTC
Oh the more detailed explanation is in bug #509965.
Comment 4 klese176 2011-10-28 18:44:49 UTC
Many thanks for the explanation. One of my students (17 years) came up with calculation. Now I may try to explain it to him.
Comment 5 Andreas J. Guelzow 2011-10-28 19:44:42 UTC
I would think it the easiest if you first explain it in terms of decimal representations:

We all know that 1/3 + 1/3 + 1/3 - 1 = 0 
but if you wrote them as decimals with a fixed number (say 4) of decimal digits, then we have:

0.3333 + 0.3333 + 0.3333 - 1.000 = 0.9999 - 1.000 = -0.0001

and only then transfer it to binary where the closest approximation of 1/3 is 0.0101 (=5/16):

0.0101 + 0.0101 + 0.0101 - 1.0000 = 0.1111 - 1.0000 = - 0.0001 (or -1/16)

In computers numbers of the same magnitude are represented with  the same number of fractional binary digits, just much more than 4.

Good luck!