HP Pascal/iX Programmer's Guide (31502-90023)
5-: 20
Table 5-8. Allocation and Alignment of Packed Array Elements of Enumeration or Subrange
Type (HP Pascal Packing Algorithm)
---------------------------------------------------------------------------------------
||||
| Required Number of | Number of Bits | Alignment |
| Bits Per Element | Allocated Per Element ||
||||
---------------------------------------------------------------------------------------
||||
|1 |1 |Bit|
||||
---------------------------------------------------------------------------------------
||||
| 2 | 2 | 2-bit |
||||
---------------------------------------------------------------------------------------
||||
| 3 or 4 | 4 | 4-bit |
||||
---------------------------------------------------------------------------------------
||||
| 5 to 8 | 8 (1 byte) | Byte |
||||
---------------------------------------------------------------------------------------
||||
| 9 to 16 | 16 (2 bytes) | 2-byte |
||||
---------------------------------------------------------------------------------------
||||
| 17 to 32 | 32 (4 bytes) | 4-byte |
||||
---------------------------------------------------------------------------------------
Example
TYPE
direction = (north,south,east,west);
day = (sun,mon,tues,wed,thurs,fri,sat);
VAR
pa1 = PACKED ARRAY [1..5] OF direction;
pa2 = PACKED ARRAY [1..5] OF day;
Each element of the array
pa1
requires two bits. Two is a power of two,
so each element is allocated two bits. The entire array occupies 10
bits. It is allocated two bytes:
Each element of the array
pa2
requires three bits. The smallest power of
two that is greater than or equal to three is four, so each element is
allocated four bits. The entire array occupies 20 bits. It is allocated
three bytes: