Code: Select all
' Square Roots!
' by Kristopher Windsor
Function squareroot (Byval number As Double ) As Double
Dim As Double r1=1, r2=Any
Do
r2 = r1
r1 = (r1 + number / r1) * .5
Loop Until Abs(r1 - r2) < .001
Return r1
End Function
Dim As Double t,a
t=Timer
for i as integer = 1 to 10000:a = Sqr(666666669911):next
? timer-t
t=Timer
for i as integer = 1 to 10000:a = Squareroot(666666669911):next
? timer-t
Sleep