HP Pascal/iX Reference Manual (31502-90022)

11- 42
The bitsizeof function returns the number of bits needed to represent the
data value part of a data item of the given type, or the actual allocated
size of a variable. If the first parameter is a record type or variable
with variants, a variant may be selected by specifying a case constant
with the subsequent parameters. Otherwise, the size with the largest
variant is used.
bitsizeof
(type)
returns the minimum number of bits of storage for the
type, and bitsizeof
(variable)
returns the number of bits of storage for
the variable.
For an ANYVAR parameter, two cases exist: If an additional hidden size
parameter is passed along with the ANYVAR parameter, bitsizeof gives the
number of bits in the number of bytes allocated to represent the actual
parameter. If the hidden length parameter is not passed, bitsizeof gives
the number of bits required to represent the formal parameter as a given
type.
Example
TYPE
int_type = integer;
rec_type = RECORD
int : integer;
CASE flag: Boolean OF
true: ( r : real );
false:( lr : longreal );
end;
VAR
int : int_type;
rec : rec_type;
size : integer;
BEGIN
...
size := bitsizeof( int );
size := bitsizeof( int_type );
size := bitsizeof( rec, true );
...
END;
NOTE bitsizeof is allowed in CONST declarations except for ANYVAR, VAR
string, and conformant array parameters.
Sizeof.
The predefined function sizeof returns an integer representing the size
of its argument in bytes.
Usage
sizeof
(variable)
sizeof
(record_variable,tag_value ...)
sizeof
(type_name)
sizeof
(record_type_name,tag_value ...)
sizeof
(struct_constant)
sizeof
(string_literal)
Parameters
variable
The name of a variable.
record_variable
The name of a record variable with variants.