Non-decimal radices/Convert: Difference between revisions

m
→‎{{header|REXX}}: made some cosmetic changes.
m (→‎{{header|REXX}}: changed/added comments and whitespace, changed indentations.)
m (→‎{{header|REXX}}: made some cosmetic changes.)
Line 1,969:
maxB=length(@@) /*max base/radix supported in this code*/
parse arg x toB inB 1 ox . 1 sigX 2 x2 . /*obtain: three args, origX, sign ··· */
if pos(sigX, "+-")\==0 then x=x2 /*does X have a leading sign (+ or -) ?*/
else sigX= /*Nope. No leading sign for the X value*/
if x=='' then call erm /*if no X number, issue an error msg.*/
if toB=='' | toB=="," then toB=10 /*if skipped, assume the default (10). */
if inB=='' | inB=="," then inB=10 /* " " " " " " */
if inB<2 | inB>maxB | \datatype(inB,'W') then call erb '"inBase '" inB
if toB<2 | toB>maxB | \datatype(toB,'W') then call erb '"toBase '" toB
#=0 /*result of converted X (in base 10).*/
do j=1 for length(x) /*convert X: base inB ──► base 10. */
Line 1,990:
/* [↓] Y is the residual. */
y=sigX || substr(@@, #+1, 1)y /*prepend the sign if it existed. */
say ox "(base" inB')' center('"is'",20) y " '(base"' toB'")'"
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/