From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,86d4e48d5a9b02a1 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!s5g2000yqm.googlegroups.com!not-for-mail From: Gautier write-only Newsgroups: comp.lang.ada Subject: Re: Cannot summate small float values Date: Sun, 21 Nov 2010 17:23:17 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <8kq1usFojgU1@mid.individual.net> NNTP-Posting-Host: 62.203.43.103 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1290388997 1350 127.0.0.1 (22 Nov 2010 01:23:17 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 22 Nov 2010 01:23:17 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s5g2000yqm.googlegroups.com; posting-host=62.203.43.103; posting-account=gRqrnQkAAAAC_02ynnhqGk1VRQlve6ZG User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.342.9 Safari/533.2,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:15633 Date: 2010-11-21T17:23:17-08:00 List-Id: On 21 nov, 22:06, tolkamp wrote: > Thank you your reaction. > Using your procedure Sums I found out that when the start value of X < > 0.24 the summation works correct with Dx = 1.0E-8 > When start X > 0.25 the summation remains 0.250000000. Anyway, since Dx is constant, you should never add it over and over: it will accumulate numerical errors (with very rare exceptions) even if it looks to work correctly on a few iterations. The right way is X:= N * Real(Dx); N:= N + 1; where Real is your floating-point type. Cheers ______________________________________________________________ Gautier's Ada programming -- http://gautiersblog.blogspot.com/ NB: follow the above link for a working e-mail address