HP Pascal/iX Programmer's Guide (31502-90023)

5-: 25
To minimize storage space, avoid base types that are small subranges that
overlap set chunk boundaries.
Example 3
VAR
s1 : SET OF 31..32;
s2 : PACKED SET OF 15..16;
The set s1 takes two 32-bit set chunks, using 64 bits to represent a set
that requires only two bits. The arithmetic is: (floor(32/32) -
floor(31/32)) + 1 = (1-0) + 1 = 2.
The PACKED set
s2
takes two 8-bit set chunks, using 16 bits to represent
a set that requires only two bits. The arithmetic is: (floor(16/8) -
floor(15/8)) + 1 = (2-1)+1 = 2.
Strings
A string is allocated four bytes for its current length (an integer), one
byte per character, and one "housekeeping" byte. The number of
characters is the string's declared maximum length. The "housekeeping"
byte is only accessible to some of the standard string functions.
The HP Pascal packing algorithm aligns strings on 4-byte boundaries in
all structures. Because the current length (an integer) is allocated
four bytes, eight bytes is the smallest possible string allocation.