This example shows one value of one of the numbers
in the decode2 example and how it is processed and stored, from start to finish.
-- Types, and functions:
type BitArray32 is ...
function INT_TO_BITARRAY32 is new unchecked_conversion(Integer, BitArray32);
function swap_nibbles(x: BitArray32) return BitArray32 is ... -- Assume it exists
subtype Str4 is String(1 .. 4)
function BITARRAY32_TO_STR4 is new unchecked_conversion(BITARRAY32, Str4);
-- DATAFLOW: Values are shown indented, in various forms.
-- Data transformations are shown in column 1
One of the integers from the file decode2.txt,
8 ASCII characters, as rendered by editor:
43308546
64 bits show how that number is actually stored in the file (spaces added for readability):
0011 0100 0011 0011 0011 0011 0011 0000 0011 1000 0011 0101 0011 1001 0011 0110
hex version of bits that are stored:
34 33 33 30 38 35 34 36
i: Integer
GET(i)
Contents of i:
32 bits that are actually stored (spaces added for readability):
0000 0010 1001 0100 1101 0110 0000 0010
hex version of bits that are stored
02 94 D6 02
b: BitArray32 := INT_TO_BITARRAY32(i);
Contents of b:
32 bits that are actually stored (spaces added for readability):
0000 0010 1001 0100 1101 0110 0000 0010
hex version of bits that are stored
02 94 D6 02
c: BitArray32 := swap_nibbles(b); -- Assume it exists
Contents of c:
32 bits that are actually stored (spaces added for readability):
0010 0000 0100 1001 0110 1101 0010 0000
hex version of bits that are stored
20 49 6D 20
s4: Str4 := BITARRAY32_TO_STR4(i)
Contents of s4 (which are identical to i at the bit level)
32 bits that are actually stored (spaces added for readability):
0010 0000 0100 1001 0110 1101 0010 0000
hex version of bits that are stored
20 49 6D 20
PUT("<" & s4 & ">");
Output from put command (ie printed as string with <> to show blanks):
< Im >