Anonymous user
Literals/Integer: Difference between revisions
→{{header|REXX}}: added/changed comments and whitespace, used a template for the output, used a different decimal value so that the REXX pgm displays both a viewable ASCII and EBCDIC character, shown more examples with blanks in them for readability.
(→{{header|REXX}}: added/changed comments and whitespace, used a template for the output, used a different decimal value so that the REXX pgm displays both a viewable ASCII and EBCDIC character, shown more examples with blanks in them for readability.) |
|||
Line 1,378:
=={{header|REXX}}==
<lang rexx>/*REXX pgm displays an integer (expressed in the pgm as a literal) in different bases*/
/*────────── expressing hexadecimal numbers ──────*/
hhh = '7b'x /*a value, expressed as a hexadecimal literal. */
hhh = '7B'x /* (same as above) using a capital "B". */
hhh = '7B'X /* (same as above) using a capital "X". */
cow = 'dead beef'x /*another value, with a blank for the eyeballs.*/
cow = 'de ad be ef'x /* (same as above) with blanks for the eyeballs.*/
/*────────── expressing binary numbers ───────────*/
bbb = '1111011'b /*a value, expressed as a binary literal. */
bbb = '01111011'b /* (same as above) with a full 8 binary digits. */
bbb = '0111 1011'b /* (same as above) with a blank for the eyeballs.*/
say ' base 10='
say ' base 2=' x2b( d2x(
say ' base 16=' d2x(
say ' base 256=' d2c(
thingy1= +123 /*╔══════════════════════════════════════════════╗*/
thingy2= '+123' /*║ All of the THINGYs variables aren't strictly ║*/
thingy3= ' 123' /*║ (exactly) equal to the DDD variable, but ║*/
thingy4= 123. /*║ they do compare numerically equal. When ║*/
thingy5= 12.3e+1 /*║ compared numerically, numbers are rounded to ║*/
thingy6= 1230e-1 /*║ the current setting of NUMERIC DIGITS. The ║*/
thingy7= 1230E-0001 /*║ default for (decimal) NUMERIC DIGITS is 9 ║*/
thingy8= ' + 123 ' /*╚══════════════════════════════════════════════╝*/
/*stick a fork in it, we're all done. */</lang>
{{out|output}}
<pre>
base 10=
base 2=
base 16=
base 256=
</pre>
On TSO d2c(37) does not result in a displayable character.
With thing=c2d('A') I see:
|