How to resolve the algorithm Literals/Integer step by step in the Picat programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Literals/Integer step by step in the Picat 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 Picat programming language
Source code in the picat programming language
% All outputs are in base 10
main =>
println(100), % plain integer
println(1_234_567_890), % underscores can be used for clarity
println(1_000_000_000_070_000_030_000_001), % arbitrary precision
nl,
println(0x10ABC), % Hexadecimal
println(0xBe_ad_ed_83), % lower or upper case are the same
nl,
println(0o666), % Octal
println(0o555_666_777),
nl,
println(0b1111111111111), % binary
println(0b1011_1111_1110)
You may also check:How to resolve the algorithm Narcissistic decimal number step by step in the JavaScript programming language
You may also check:How to resolve the algorithm Knuth's power tree step by step in the Raku programming language
You may also check:How to resolve the algorithm JortSort step by step in the K programming language
You may also check:How to resolve the algorithm Stack step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Reflection/List properties step by step in the REXX programming language