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

A-: 18
Sets.
The Pascal/V packing algorithm allocates sets in byte pairs. The number
of byte pairs allocated to a set depends on its type. For the types
Boolean, char, enumeration, and integer, the formula for the number of
byte pairs is:
number_of_byte_pairs
= ceil(
bits_required_for_set
/16)
(where ceil(
x
) means the integer closest to
x
that is greater than or
equal to
x
).
Table A-5 gives the values for
bits_required_for_set
and
number_of_byte_pairs
for Boolean, char, and integer types.
Table A-5. Bit and Byte Pair Requirements for Boolean, Char, and Integer Base Types
(Pascal/V Packing Algorithm)
-----------------------------------------------------------------------------------------------
| | | |
| Base Type |
bits_required_for_set
|
number_of_byte_pairs
|
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| Boolean | 2 | 1 |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| Char | 256 | 16 |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| Integer * | 256 (by default) * | 16 |
| | | |
-----------------------------------------------------------------------------------------------
* Same as bit16, bit32, bit52, shortint, and longint.
* Integers outside the range 0..255 cannot belong to the set.
For enumerated sets,
bits_required_for_set
is the number of elements in
the set, and you must use the formula to determine
number_of_byte_pairs
.
Example
VAR
days = SET OF (sun,mon,tues,wed,thurs,fri,sat);
months = SET OF (ja,f,mr,ap,ma,jn,jl,au,s,o,n,d);
set_33 = SET OF (e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,
e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,
e23,e24,e25,e26,e27,e28,e29,e30,e31,e32,e33);
The set days has seven elements and requires seven bits. It is allocated
one byte pair (ceil(7/16) = 1).
Each element is represented by one bit, like this: