From: kst@thomsoft.com (Keith Thompson)
Subject: Re: Integer Square Root
Date: 1996/10/17
Date: 1996-10-17T00:00:00+00:00 [thread overview]
Message-ID: <DzEEq3.9tI@thomsoft.com> (raw)
In-Reply-To: mheaney-ya023180001510962133390001@news.ni.net
In <mheaney-ya023180001510962133390001@news.ni.net> 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
next prev parent reply other threads:[~1996-10-17 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-10-15 0:00 Integer Square Root Matthew Heaney
1996-10-17 0:00 ` Mats Weber
1996-10-17 0:00 ` Keith Thompson [this message]
1996-10-17 0:00 ` Matthew Heaney
1996-10-22 0:00 ` Oliver Kellogg
-- strict thread matches above, loose matches on Subject: below --
1996-10-15 0:00 W. Wesley Groleau (Wes)
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox