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*/
<lang rexx>thing = 37
thing = '37' /*this is exactly the same as above. /*────────── expressing decimal numbers ──────────*/
thingddd = "37" 123 /*thisa isdecimal exactlynumber the same(expressed as abovea alsoliteral). */
thingddd = '25123'x /*this asis well,exactly expressedthe insame hexadecimalas above. */
thingddd = '00100101'b"123" /*this too,is expressed as binary.exactly the same as above also. */
/*────────── 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=' thing ddd
say ' base 2=' x2b( d2x(thing ddd ) )
say ' base 16=' d2x(thing ddd )
say ' base 256=' d2c(thing) ddd ) /*the output showndisplayed is ASCII (or maybe EBCDIC).*/</lang>
 
'''output'''
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= 37123
base 2= 0010010101111011
base 16= 257B
base 256= %{
</pre>
 
On TSO d2c(37) does not result in a displayable character.
With thing=c2d('A') I see: