Anonymous user
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>
╔══════════════════════════════════════════════════════════════════════════════════╗
║ ║
║ 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│
▲└─┐ simarily performed. ┌─┘
a=123 /*all of these assignments are identical: */
b='123'
c='1' || "2" || '3'
d= 1 || 2 || 3
e= 12 || 3
f=120 + 3
g=substr(9912388,3,
h=left(123456,3)
i=right(777.123,3)
j=
k=0000000123.0000/1 /*
/*parsing
/*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
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
cyanJ=x2c(fab) /*converts a
cyanK=x2b(fab) /*converts a
befog=d2b(144) /*there's no dec──►binary, but see below.*/
|