HP Pascal/iX Programmer's Guide (31502-90023)
5-: 24
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);
p_set_33 = PACKED 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. Its set chunk
size is four bytes (32 bits), so days is allocated one set chunk.
Each element is represented by one bit, like this:
The set months has 12 elements and requires 12 bits. Its set chunk size
is two bytes, so months is allocated one set chunk (ceil(12/(2*8))=1).
Each element is represented by one bit.
Each of the sets set_33 and p_set_33 has 33 elements and requires 33
bits. The set chunk size is four bytes, so set_33 is allocated two set
chunks (ceil(33/(4*8))=2). Each element is represented by one bit.
If the type is a subrange, the formula for the number of set chunks is:
number_of_set_chunks
=
(upper_bound_set_chunk_number
-
lower_bound_set_chunk_number
) + 1
The upper bound of the subrange determines
upper_bound_set_chunk_number
,
and the lower bound determines
lower_bound_set_chunk_number
. The formula
is:
set_chunk_number
=
floor(bound
/
set_chunk_size)
(where
floor(x)
means the integer closest to
x
that is less than or equal
to
x
).
Example 2
VAR
s : SET OF -7..18;
The set
s
is unpacked, so it has a 32-bit set chunk (see Table 5-10 ).
The upper bound of the subrange is 18, so
upper_bound_set_chunk_number
is
zero (floor(18/32=0)). The lower bound of the subrange is -7, so
lower_bound_set_chunk_number
is -1 (floor(-7/32)=-1). The set
s
is
allocated two set chunks ((0-(-1))+1=2).
Each set element is represented by one bit, like this: