Non-decimal radices/Convert: Difference between revisions
Content deleted Content added
No edit summary |
→{{header|J}}: Added examples of use and reference to #. and #: |
||
Line 177: | Line 177: | ||
2b100 8b100 10b100 16b100 36b100 36bzy |
2b100 8b100 10b100 16b100 36b100 36bzy |
||
4 64 100 256 1296 1294 |
4 64 100 256 1296 1294 |
||
Programs for conversion of numeric values to literals, and of literals to numbers: |
|||
numerals=: '0123456789abcdefghijklmnopqrstuvwxyz' |
numerals=: '0123456789abcdefghijklmnopqrstuvwxyz' |
||
baseNtoL=: numerals {~ [ #.^:_1 ] |
baseNtoL=: numerals {~ [ #.^:_1 ] |
||
baseLtoN=: (#~ #) #. numerals i. ] |
baseLtoN=: (#~ #) #. numerals i. ] |
||
Examples of use: |
|||
2 baseNtoL 100 101 |
|||
1100100 |
|||
1100101 |
|||
16 baseNtoL 26 |
|||
1a |
|||
36 baseLtoN 'zy' |
|||
1294 |
|||
See also primary verbs [http://www.jsoftware.com/help/dictionary/d401.htm Base] and [http://www.jsoftware.com/help/dictionary/d402.htm Antibase]. |
|||
=={{header|Java}}== |
=={{header|Java}}== |