Non-decimal radices/Input: Difference between revisions

m
→‎{{header|REXX}}: made some changes, moved a REXX block of comments to the prologue.
m (→‎{{header|Go}}: typo/nit: math/big.SetString supports up-to base 36 (using [0-9a-zA-Z] for each digit))
m (→‎{{header|REXX}}: made some changes, moved a REXX block of comments to the prologue.)
Line 822:
 
=={{header|REXX}}==
<pre>
╔══════════════════════════════════════════════════════════════════════════════════╗
┌─┘ In REXX, there are no numeric-type variables (integer, float, real,└─┐ unsigned, ║
logical, binary, complex, double, etc), only character. Everything is stored
as a character string. Arithmetic is done almost exactly the way a schoolchild
schoolchild would perform it. ToPutting it simply, to add, align the two numbers up (right
justified, with the decimal being the pivot) and simply add the columns│columns up, adding the ║
└─┐ simarily performed║ carries and honoring the signs. ┌─┘
║ ║
║ Multiplications and divisions are similarly performed. ║
╚══════════════════════════════════════════════════════════════════════════════════╝
</pre>
<lang rexx>/*REXX program demonstrates REXX's ability to handle non-decimal radices*/
/*┌────────────────────────────────────────────────────────────────────┐
┌─┘ In REXX, there are no numeric-type variables (integer, float, real,└─┐
│ logical, complex, double, etc), only character. Everything is stored │
│ as a character string. Arithmetic is done almost exactly the way a │
│ schoolchild would perform it. To add, align the two numbers up (right │
│ justified, with the decimal being the pivot) and simply add the columns│
│ up, noting carries and the signs. Multiplication and division are │
└─┐ simarily performed. ┌─┘
└────────────────────────────────────────────────────────────────────┘*/
a=123 /*all of these assignments are identical: */
b='123' /*there is no difference in the assignments*/
c='1' || "2" || '3'
d= 1 || 2 || 3
e= 12 || 3
f=120 + 3
g=substr(9912388,3,23)
h=left(123456,3)
i=right(777.123,3)
j=12120 + ' 3 '
k=0000000123.0000/1 /*divisondivision "normalizes the number (───►──► 123)*/
 
/*parsing then, of a decimal number is no */
/*different then parsing a character string*/
/*because decimal numbers ARE character */
Line 853 ⟶ 856:
 
aa=' 123 ' /*AA's exact value is different the A, */
/*but it's numerically equal to A. to A. */
bb=123. /*the same can be said for the rest of 'em.*/
cc=+123
Line 891 ⟶ 894:
cyanH=d2c(251) /*converts a decimal number to character. */
 
cyanI=x2d(fab) /*converts a hexadcimalhexadecimal string to decinal.decimal*/
cyanJ=x2c(fab) /*converts a hexadcimalhexadecimal string to chars. */
cyanK=x2b(fab) /*converts a hexadcimalhexadecimal string to binary. */
 
befog=d2b(144) /*there's no dec──►binary, but see below.*/