	DIM OUT/1/
	DIM X,Y,RADIUS,SQUAREDERROR,MAXERROR/0/
	DIM NEWX,NEWY,NEWERROR,THISERROR
	DIM XCENTER/255/,YCENTER/127/
	DIM CLEARSCREEN$/:0C/,HOME$/:1B," 0 255"/
	DIM DOTCURSORXY$/:1B,"!"/
	DIM FILE$(50)
	DIM MOVETO$/:1B," "/
	WRITE #0,CLEARSCREEN$
	INPUT "WHERE TO WITH THE RESULTS? " FILE$
	CREATE #OUT,FILE$
10	WRITE #OUT, HOME$
	INPUT "RADIUS ? " RADIUS
	IF RADIUS<0 OR RADIUS<>INT(RADIUS) OR RADIUS>127 THEN 10
	WRITE #OUT, CLEARSCREEN$
20	LET X=RADIUS
	LET Y=0
	LET SQUAREDERROR=0
	LET MAXERROR=0
100	IF Y>=X THEN 200
	LET THISERROR=ABS(SQR(X*X+Y*Y)-RADIUS)
	IF THISERROR>MAXERROR THEN LET MAXERROR=THISERROR
	WRITE #OUT, DOTCURSORXY$\PRINT #OUT,XCENTER+X;YCENTER+Y
	WRITE #OUT, DOTCURSORXY$\PRINT #OUT,XCENTER+X;YCENTER-Y
	WRITE #OUT, DOTCURSORXY$\PRINT #OUT,XCENTER-Y;YCENTER+X
	WRITE #OUT, DOTCURSORXY$\PRINT #OUT,XCENTER-Y;YCENTER-X
	WRITE #OUT, DOTCURSORXY$\PRINT #OUT,XCENTER-X;YCENTER-Y
	WRITE #OUT, DOTCURSORXY$\PRINT #OUT,XCENTER-X;YCENTER+Y
	WRITE #OUT, DOTCURSORXY$\PRINT #OUT,XCENTER+Y;YCENTER-X
	WRITE #OUT, DOTCURSORXY$\PRINT #OUT,XCENTER+Y;YCENTER+X
	LET NEWY=Y+1
	IF 0<2*SQUAREDERROR-2*X+4*Y+3
	THEN LET NEWX=X-1\
	     LET NEWERROR=SQUAREDERROR+2*Y-2*X+2
	ELSE LET NEWX=X\
	     LET NEWERROR=SQUAREDERROR+2*Y+1
	LET X=NEWX
	LET Y=NEWY
	LET SQUAREDERROR=NEWERROR
	GOTO 100

200	WRITE #OUT, MOVETO$\PRINT #OUT,0;200
	PRINT #OUT,"MAX ERROR = ";MAXERROR
	GOTO 10

	END
