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 608889 - SUM should be more exact
SUM should be more exact
Status: RESOLVED DUPLICATE of bug 170000
Product: Gnumeric
Classification: Applications
Component: Analytics
git master
Other All
: Low normal
: ---
Assigned To: Morten Welinder
Jody Goldberg
Depends on:
Blocks:
 
 
Reported: 2010-02-03 14:20 UTC by Andreas J. Guelzow
Modified: 2010-07-28 19:53 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Andreas J. Guelzow 2010-02-03 14:20:50 UTC
SUM really should take more care of how to add:

A1:  =10^300
A2:  =PI()*10^-100
A3:  =-(10^300)

A5: = SUM(A1:A3)
A6: = SUM(A1,A3,A2)

then A5 and A6 should really contain the same answer but SUM seems to just add the numbers in given order.
Comment 1 Morten Welinder 2010-02-03 16:19:10 UTC
This has popped up before.

The current state of affairs is that we add in the given order using
long double, if available.  (This is not to be confused with --with-
long-double.)

Various other addition methodologies have been proposed, but I have
not seen any that do not just make an equally bad situation pop up
elsewhere.
Comment 2 Morten Welinder 2010-05-01 00:46:26 UTC
If we are going to solve this -- and that is a fairly big "if" -- then I
believe we are going to have to do

1. Add exactly.  That means with up to thousands of bits precision.
   Gnu mpl can do this.

2. Come up with a smart ordering.  The best I can think of is...

   (a) discard zeros.
   (b) while (multiple addends)
         either
            pick two numbers that can be machine added exactly
         or
            pick two numbers with smallest possible sum
         replace the two numbers with their sum

   In the mixed-sign case I have the feeling that this is very, very
   expensive.
Comment 3 Jason Mancini 2010-05-17 22:11:12 UTC
Order by absolute size (large to small).  Sum!
Comment 4 Morten Welinder 2010-05-17 23:05:21 UTC
> Order by absolute size (large to small).  Sum!

Worst possible when all terms are positive.
Comment 5 Jason Mancini 2010-05-17 23:20:12 UTC
Ah, now I see what the poster meant about matching up numbers for small sums first -- very interesting problem indeed.
Comment 6 Andreas J. Guelzow 2010-07-28 19:53:58 UTC
While this is not exactly bug #170000, it is the same general issue.

So I'll mark it as a duplicate of that.

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