Literals/Integer: Difference between revisions

Content deleted Content added
Rdm (talk | contribs)
m J: clarify description
Line 23:
</pre>
=={{header|ALGOL 68}}==
{{trans|Fortran}}
 
{{works with|ALGOL 68|StandardRevision 1 - no extensions to language used}}
 
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}}
{{works with|ELLA ALGOL 6868G|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68g/algol68g-1.818.8d0/algol68g-1.fc918.0-9h.tiny.el5.centos.fc11.i386.rpm/download 1.18.0-9h.tiny]}}
 
Binary constants are of type BITS, and need to be converted
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d]}}
 
Binary constantsliterals are of type BITS, and need to be converted
to INT using the operator ABS.
<lang algol68>main:(
SHORT SHORT INT decssdec = SHORT SHORT 727;,
INT hex sshex = ABS SHORT SHORT 16r2d7;,
INT oct ssoct = ABS SHORT SHORT 8r1327;,
INT bin ssbin = ABS SHORT SHORT 2r1011010111;
 
SHORT INT sdec = SHORT 727,
print((dec, hex, oct, bin, new line))
shex = ABS SHORT 16r2d7,
soct = ABS SHORT 8r1327,
sbin = ABS SHORT 2r1011010111;
 
INT dec = 727,
hex = ABS 16r2d7,
oct = ABS 8r1327,
bin = ABS 2r1011010111;
LONG INT ldec = LONG 727,
lhex = ABS LONG 16r2d7,
loct = ABS LONG 8r1327,
lbin = ABS LONG 2r1011010111;
 
CO
LONG LONG INT lldec = LONG LONG 727,
llhex = ABS LONG LONG 16r2d7,
lloct = ABS LONG LONG 8r1327,
llbin = ABS LONG LONG 2r1011010111
# etc ... #
END CO
 
print(("SHORT SHORT INT:", ssdec, sshex, ssoct, ssbin, new line));
print((" SHORT INT:", sdec, shex, soct, sbin, new line));
print((" INT:", dec, hex, oct, bin, new line));
print((" LONG INT:", ldec, lhex, loct, lbin, new line))
CO LONG LONG INT not supported by ELLA ALGOL 68RS
print(("LONG LONG INT:", new line, lldec, new line, llhex, new line, lloct, new line, llbin, new line))
# etc ... #
END CO
 
)</lang>
[http://sourceforge.net/projects/algol68/files/algol68g/algol68g-1.18.0/algol68g-1.18.0-9h.tiny.el5.centos.fc11.i386.rpm/download algol68g] output:
Output:
<pre>
<lang algol68>+727 +727 +727 +727</lang>
SHORT SHORT INT: -41 -41 -41 -41
SHORT INT: +727 +727 +727 +727
<lang algol68> INT: +727 +727 +727 +727</lang>
LONG INT: +727 +727 +727 +727
 
</pre>
[http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download algol68toc] output:
<pre>
SHORT SHORT INT: +727 +727 +727 +727
SHORT INT: +727 +727 +727 +727
INT: +727 +727 +727 +727
LONG INT: +727 +727 +727 +727
</pre>
 
=={{header|AmigaE}}==