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

A-: 27
Table A-9 shows the relationship between the number of bits that an
element of a PACKED array of subrange type requires, the number of bits
that the Pascal/V mapping algorithm allocates it, and its alignment.
Table A-9. Allocation and Alignment of Elements of Packed Arrays of Subrange Type
(Pascal/V Packing Algorithm)
-----------------------------------------------------------------------------------------------
| | | |
| Required Number of Bits | Number of Bits Allocated | Alignment |
| Per Element * | Per Element | |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| 1 | 1 | Bit |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| 2 | 2 | Bit |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| 3 | 3 | Bit |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| 4 | 4 | Bit |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| 5 | 5 | Bit |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| 6 to 8 | 8 (1 byte) | Byte |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| 9 to 16 | 16 (2 bytes) | 2-byte |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| 32 | 32 (4 bytes) | 2-byte |
| | | |
-----------------------------------------------------------------------------------------------
* Only if the subrange is, or is included in, -32768..32767; four bytes
otherwise.
Example
VAR
a : PACKED ARRAY [1..4] OF 0..16;
b : PACKED ARRAY [1..4] OF 0..32;
Each element of the array a requires and is allocated five bits, and is
bit-aligned (see Table A-8 ). The entire array occupies 20 bits. It
is allocated four bytes:
Each element of the array b requires six bits, is allocated one byte, and
is byte-aligned (see Table A-8 ). The entire array occupies four
bytes.