Circles of given radius through two points: Difference between revisions

m
→‎{{header|REXX}}: handled case of lowercase E in a number, added/changed whitespace and comments.
m (→‎{{header|REXX}}: handled case of lowercase E in a number, added/changed whitespace and comments.)
Line 2,743:
{{trans|XPL0}}
<br>The REXX language doesn't have a &nbsp; '''sqrt''' &nbsp; function, &nbsp; so one is included below.
<lang rexx>/*REXX programpgm finds two circles with a specific radius given two (XX1,YY1) & points. (X2,Y2) points*/
@.=; @.1= 0.1234 0.9876 0.8765 0.2345 2
@.2= 0 2 0 0 1
Line 2,752:
say ' ════════ ════════ ════════ ════════ ══════ ════════ ════════ ════════ ════════'
do j=1 while @.j\==''; parse var @.j p1 p2 p3 p4 r /*points, radii*/
say f(p1) f(p2) f(p3) f(p4) center(r/1, 9) "───► " 2circ(@.j)
end /*j*/
exit /*stick a fork in it, we're all done. */
Line 2,764:
return f(bx-x1) f(by+y1) f(bx+x1) f(by-y1)
/*──────────────────────────────────────────────────────────────────────────────────────*/
f: arg f; f= right( format( arg(1)f, , 4), 9); _=f f /*format # with 4 dec digits*/
if pos(.,f)>0 & pos('E',f)=0 then f= strip(f,'T',0) /*strip trailing 0s if .& ¬E*/
return left( strip(f, 'T', .), length(_)) ) /*strip trailing dec point. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
sqrt: procedure; arg x; if x=0 then return 0; d=digits(); numeric digits; h=d+6; m.=9
numeric form; parse value format(x,2,1,,0) 'E0' with g "E" _ .; g=g *.5'e'_ % 2
do j=0 while h>9; m.j=h; h=h%2+1; end /*j*/
do k=j+5 to 0 by -1; numeric digits m.k; g=(g+x/g)*.5; end /*k*/; return g</lang>
{{out|output}}
<pre>