How to resolve the algorithm Literals/Integer step by step in the ALGOL 68 programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Literals/Integer step by step in the ALGOL 68 programming language
Table of Contents
Problem Statement
Some programming languages have ways of expressing integer literals in bases other than the normal base ten.
Show how integer literals can be expressed in as many bases as your language allows.
Note: this should not involve the calling of any functions/methods, but should be interpreted by the compiler or interpreter as an integer written to a given base. Also show any other ways of expressing literals, e.g. for different types of integers.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Literals/Integer step by step in the ALGOL 68 programming language
Source code in the algol programming language
main:(
SHORT SHORT INT ssdec = SHORT SHORT 727,
sshex = ABS SHORT SHORT 16r2d7,
ssoct = ABS SHORT SHORT 8r1327,
ssbin = ABS SHORT SHORT 2r1011010111;
SHORT INT sdec = SHORT 727,
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
)
You may also check:How to resolve the algorithm XML/XPath step by step in the Java programming language
You may also check:How to resolve the algorithm Increasing gaps between consecutive Niven numbers step by step in the x86-64 Assembly programming language
You may also check:How to resolve the algorithm Strip a set of characters from a string step by step in the 8080 Assembly programming language
You may also check:How to resolve the algorithm Logical operations step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Chinese zodiac step by step in the Dart programming language