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!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s22.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Unsigned Integer Restraint Errors 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> <1173799893.510392.45910@j27g2000cwj.googlegroups.com> In-Reply-To: <1173799893.510392.45910@j27g2000cwj.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.213 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s22 1173802872 12.201.97.213 (Tue, 13 Mar 2007 16:21:12 GMT) NNTP-Posting-Date: Tue, 13 Mar 2007 16:21:12 GMT Organization: AT&T ASP.att.net Date: Tue, 13 Mar 2007 16:21:12 GMT Xref: g2news1.google.com comp.lang.ada:14517 Date: 2007-03-13T16:21:12+00:00 List-Id: frikk wrote: > On Mar 13, 10:58 am, "frikk" wrote: >> >> m := Integer(100**(0.5)+1); >> > Actually I need to specify - I really used (1/2), not (0.5). I'm not > sure how that got in the code I posted... > > But this would mean that the (1/2) is being converted to an Int - > which would be 0. anything ^ 0 = 1, and 1+1 = 2. So there, I know > why it is happening. 1/2 is an integer expression, and unless you've redefined "/", it truncates towards zero. So you're correct; 1/2 = 0. > But how else can I compute a square root? Take a look at the standard library in Annex A, especially Ada.Numerics (A.5) and its children. You might find A.5.1, "Elementary Functions", helpful. -- Jeff Carter "If you don't get the President of the United States on that phone, ... you're going to have to answer to the Coca-Cola Company." Dr. Strangelove 32