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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b2923d60cb81694b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!h3g2000cwc.googlegroups.com!not-for-mail From: "Adam Beneschan" Newsgroups: comp.lang.ada Subject: Re: Unsigned Integer Restraint Errors Date: 13 Mar 2007 10:31:57 -0700 Organization: http://groups.google.com Message-ID: <1173807117.252152.63410@h3g2000cwc.googlegroups.com> References: <1173712032.183064.264340@8g2000cwh.googlegroups.com> <1173726806.656979.305660@8g2000cwh.googlegroups.com> <1173787790.826099.287610@s48g2000cws.googlegroups.com> <1173797935.875023.7590@p10g2000cwp.googlegroups.com> <1173801854.505211.245650@64g2000cwx.googlegroups.com> <10l92gksnkfjl$.1rhbr6sokrtjy.dlg@40tude.net> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1173807122 13385 127.0.0.1 (13 Mar 2007 17:32:02 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 13 Mar 2007 17:32:02 +0000 (UTC) In-Reply-To: <10l92gksnkfjl$.1rhbr6sokrtjy.dlg@40tude.net> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: h3g2000cwc.googlegroups.com; posting-host=66.126.103.122; posting-account=cw1zeQwAAABOY2vF_g6V_9cdsyY_wV9w Xref: g2news1.google.com comp.lang.ada:14522 Date: 2007-03-13T10:31:57-07:00 List-Id: On Mar 13, 10:23 am, "Dmitry A. Kazakov" wrote: > > BTW, the arithmetic complexity can be further "reduced" by removing > multiplication and computing k**2 using binomial decomposition > (k+1)*(k+1)=k*k+2*k+1. So it could be: > > quadratic := 1; -- k*k, k=1 > linear := 2; -- 2*k+1, k=1 > > loop > linear := linear + 2; -- 2*k+1 > quadratic := quadratic + linear; -- k*k > exit when k>=n; > ... > end loop; Yep, that's certainly the way I'd do it on some of the *really* bare- bones computers I occasionally had to work with---like the 6502 (used in the Apple II). Some of those chips, including the 6502, didn't come with integer multiplication or division. -- Adam