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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5b88cd8e97eaef79 X-Google-Attributes: gid103376,public From: kst@thomsoft.com (Keith Thompson) Subject: Re: Integer Square Root Date: 1996/10/17 Message-ID: #1/1 X-Deja-AN: 189975725 sender: news@thomsoft.com (USENET News Admin @flash) x-nntp-posting-host: pulsar references: organization: Thomson Software Products, San Diego, CA, USA newsgroups: comp.lang.ada originator: kst@pulsar Date: 1996-10-17T00:00:00+00:00 List-Id: In mheaney@ni.net (Matthew Heaney) writes: [...] > That I did that off the top of my head, without any testing (neither static > nor dynamic), and the fact that that algorithm basically doesn't work, > should prove to everyone (especially me) that "off-the-cuff" programming > doesn't work! Thank you, Wes, for pointing out to me the errors of my > ways. > > So here, if I may be given a chance to right my wrongs, is a "correct" version: > > function Square_Root (N : Natural) return Natural is [...] Sorry, but this still doesn't work. It says the square root of 6 is 3. If it's supposed to truncate, Square_Root(6) should return 2; if it's supposed to round, sqrt(6.0) = 2.4495 (approximately), so Square_Root(6) should still return 2. It also doesn't always return increasing values for increasing numbers; Square_Root(135) returns 12 and Square_Root(136) returns 11. -- Keith Thompson (The_Other_Keith) kst@thomsoft.com <*> TeleSoft^H^H^H^H^H^H^H^H Alsys^H^H^H^H^H Thomson Software Products 10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2706 FIJAGDWOL