HP Pascal/iX Reference Manual (31502-90022)

11- 8
Figure 11-4. Layout of a Crunched Record
Note that there are no wasted bits between fields in the crunched record.
The number of bits used to represent each component of a crunched
structured type is the minimum needed to represent the values associated
with that component. The calculation of the minimum number of bits for
various types is:
* Record, Array Types.
The sum of the minimum number of bits required to represent
each component. If the record has variants, consider the
size of the largest variant.
* Set Types (of the form set of low .. high).
The ordinal value of high minus the ordinal value of low
plus one:
ord(high) - ord(low) + 1
* Char and Enumeration Based Types (of the form low .. high).
The next larger integer (the ceiling) of the logarithm base
2 of the successor of the ordinal value of the upper bound,
or one, whichever is greater:
max( ceil [ log2( ord(high) + 1 ) ], 1 )
Integer Based Types (of the form low .. high)
The next larger integer (the ceiling) of the logarithm base
2 of the maximum of the absolute value of the ordinal value
of the lower bound, and the successor of the absolute value
of the ordinal value of the upper bound, or one, whichever
is greater:
max( ceil [ log2( max( |low|, |high| + 1 ) ) ], 1 )
If the type is signed (the lower bound is less than zero),
then add one to the size.
Table 11-3 shows the lower and upper bound ranges and number of bits
allocated for unsigned subranges. Table 11-4 gives the same
information for signed subranges.