How to resolve the algorithm Literals/Integer step by step in the FreeBASIC programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Literals/Integer step by step in the FreeBASIC 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 FreeBASIC programming language
Source code in the freebasic programming language
' FB 1.05.0 Win64
' The following all print 64 to the console
' integer literals of unspecified type - actual type is inferred from size or context (8, 16, 32 or 64 bit signed/unsigned)
Print 64 '' Decimal literal
Print &H40 '' Hexadecimal literal
Print &O100 '' Octal Literal
Print &B1000000 '' Binary literal
' integer literals of specific types
' Integer type is 4 bytes on 32 bit and 8 bytes on 64 bit platform
Print 64% '' Decimal signed 4/8 byte integer (Integer)
Print 64L '' Decimal signed 4 byte integer (Long)
Print 64& '' Decimal signed 4 byte integer (Long) - alternative suffix
Print 64LL '' Decimal unsigned 4 byte integer (ULong)
Print 64LL '' Decimal signed 8 byte integer (LongInt)
Print 64ULL '' Decimal unsigned 8 byte integer (ULongInt)
Sleep
You may also check:How to resolve the algorithm Array length step by step in the zkl programming language
You may also check:How to resolve the algorithm List rooted trees step by step in the Lua programming language
You may also check:How to resolve the algorithm Euler's sum of powers conjecture step by step in the Bracmat programming language
You may also check:How to resolve the algorithm String length step by step in the Modula-3 programming language
You may also check:How to resolve the algorithm Truncatable primes step by step in the Mathematica/Wolfram Language programming language