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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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!n59g2000hsh.googlegroups.com!not-for-mail From: "frikk" Newsgroups: comp.lang.ada Subject: Re: Unsigned Integer Restraint Errors Date: 14 Mar 2007 07:06:56 -0700 Organization: http://groups.google.com Message-ID: <1173881216.461609.273200@n59g2000hsh.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> <1173804099.317171.256990@p10g2000cwp.googlegroups.com> <1173804176.860500.227030@n33g2000cwc.googlegroups.com> NNTP-Posting-Host: 12.129.98.129 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1173881218 31745 127.0.0.1 (14 Mar 2007 14:06:58 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 14 Mar 2007 14:06:58 +0000 (UTC) In-Reply-To: <1173804176.860500.227030@n33g2000cwc.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 TRY0PX01 Complaints-To: groups-abuse@google.com Injection-Info: n59g2000hsh.googlegroups.com; posting-host=12.129.98.129; posting-account=192wHg0AAAAzciSzoZsEBI9bw5pVCopO Xref: g2news1.google.com comp.lang.ada:14530 Date: 2007-03-14T07:06:56-07:00 List-Id: On Mar 13, 12:42 pm, "Adam Beneschan" wrote: > On Mar 13, 9:41 am, "Adam Beneschan" wrote: > > > On Mar 13, 9:04 am, "Adam Beneschan" wrote: > > > > By the way, if I were going to write a loop that goes from 2 to > > > sqrt(n)/2 + 1, I wouldn't use Sqrt like this: > > > > for I in 2 .. Integer(Float'Floor(Sqrt(Float(N))/2.0)) + 1 loop... > > > > but rather, I'd just write it something like this: > > > > I := 2; > > > while (2 * I - 1) * (2 * I - 1) <= N loop -- I think I got this > > > right > > > No, I didn't. Jeff did. I must have read (sqrt(n)+1)/2 or > > something. Oops. > > Ooops again---I meant Dmitry, not Jeff. Wow, I'm off to a really good > start today. > > -- Adam It seems we're all a little bit fuzzy - I actually mean sqrt(n)+1 ... why I put sqrt(n)/2+1 is beyond me. Thank you for the great information everyone. I like the idea of doing the integer arithmetic better than the square root anyway. I ended up doing this: I = 2; while (I)*(I) <= N loop ... I = I+1; Thanks! Blaine