HP Pascal/iX Programmer's Guide (31502-90023)
A-: 19
The set months has 12 elements and requires 12 bits. It is allocated one
byte pair (ceil(12/16) = 1). Each element is represented by one bit.
The set set_33 has 33 elements and requires 33 bits. It is allocated
three byte pairs (ceil(33/16) = 3). Each element is represented by one
bit.
For integer subrange sets, the formula for the number of byte pairs is:
number_of_byte_pairs
= (
upper_bound_byte_pair_number
-
lower_bound_byte_pair_number
) + 1
The upper bound of the integer subrange determines
upper_bound_byte_pair_number
, and the lower bound determines
lower_bound_byte_pair_number
. The formula is:
byte_pair_number
= floor(
bound
/ 16)
(where floor(
x
) means the integer closest to
x
that is less than or equal
to
x
).
Example
VAR
s : SET OF -7..18;
The upper bound of the subrange is 18, so
upper_bound_byte_pair_number
is
1 (floor(18/16)=1). The lower bound of the subrange is -7, so
lower_bound_byte_pair_number
is -1 (floor(-7/16)=-1). The set s is
allocated three byte pairs ((1-(-1))+1=3).
Each set element is represented by one bit, like this: