🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.forth
Article #237

sqrt

#237
From: Rick Peralta
Date: Fri, 06 Sep 1985 14:21
35 lines
1074 bytes
This is'nt really quick or smart, but I think it works for most cases.

N - the number to find the root of.
R - resolution of the answer.
I - latest increment.
V - latest value to test.

sqrt(N)
{
    R = .01
    I = N / 2
    V = I
    if (N < 0) barf

    loop:
	I = N / 2
	if ( (V*V) > N+R )
	{
	    V = V - I
	    goto loop
	}
	else
	if ( (V*V) < N-R ) 
	{
	    V = V + I
	    goto loop
	}
    return V
}

Sorry for the pseudo code, I don't speak forth too well.

Rick  ...!cybvax0[!dmc0]!fbp

"Life is a compromise"
Technical Details
Message-ID: <728@cybvax0.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!cybvax0!fbp

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site cybvax0.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!cybvax0!fbp
From: fbp@cybvax0.UUCP (Rick Peralta)
Newsgroups: net.lang.forth
Subject: sqrt
Message-ID: <728@cybvax0.UUCP>
Date: Fri, 6-Sep-85 10:21:41 EDT
Article-I.D.: cybvax0.728
Posted: Fri Sep  6 10:21:41 1985
Date-Received: Sat, 7-Sep-85 07:12:22 EDT
Distribution: na
Organization: Cybermation, Inc., Cambridge, MA
Lines: 35