Converts bit patterns between integers, pointers of set bits and textual descriptions (R.W. Payne).
|Controls printed output (
||Labels for the individual bits; default
||Separator between the bit labels in the description; default
||Bit patterns to convert|
||Bit patterns as integers|
||Bits that are set in each bit pattern|
||Textual description of each bit pattern|
Bit patterns are used by Genstat, and many other programs, to represent sets of objects like, for example, the factors and variates in a model term. Internally, they are stored in integers with a bit (i.e. a digit in the binary representation of the integer) for each object. The bit is set to one if the bit pattern contains the object, and zero otherwise. The contents of the bit patterns are then determined by logical
AND operations, but this is not easy or convenient for implementers when debugging a program.
BPCONVERT is therefore provided to enable a bit pattern to be converted between different representations: an integer (as above), a pointer with an element for each of the bits that is set in the bit pattern, a text containing the string (e.g.
blocks.plots) that would represent the bit pattern in output.
DATA parameter supplies the bit pattern to convert, in any of the three representations. The
BP parameter can save it as an integer (in a scalar). The
CONTENTS parameter can save it in a pointer. The
DESCRIPTION parameter can save the textual description (in a text).
BITS option provides the information to label the bits in
DESCRIPTION. This can be textual labels (in a text), numbers (in a variate) or identifiers of data structures (in a pointer); the default is to use the integers 1-31. The
SEPARATOR option specifies the separator to use between the labels in descriptions; by default this is a dot.
CAPTION 'BPCONVERT example'; STYLE=meta BPCONVERT [BITS=!P(A,B,C,D,E,F,G,H)] 170; CONTENTS=Factors PRINT Factors