[Coco] Color BASIC SQR(2) or 2^0.5

Melanie and John Mark Mobley johnmarkmelanie at gmail.com
Wed Feb 4 23:32:58 EST 2015


If you need a SQR function for the 1980 4K CoCo Programming Challenge try
the code below.
This is a successive approximation SQR subroutine.

10000 REM Y=SQR(X)
10010 K=0
10020 J=4294967296
10030 FOR I=1 TO 32
10040 K=K+J
10050 Y=K/65536
10060 IF Y*Y>X THEN K=K-J
10070 J=J/2
10080 NEXT I
10090 Y=K/65536
10100 RETURN

John Mark Mobley




More information about the Coco mailing list