Logical Expressions - Relational Operators for Bit Masks

When you use this variant, the right-hand operand must have type X or XSTRING; the left-hand operand may have any type, but it is not interpreted. In particular, this means that it is not converted into type X.
f2 is interpreted as a "bit mask". The comparison refers only to those bits in f1 which have the value 1 in f2. If f1 is shorter than f2, f1 is implicitly filled up with 0 bytes.

In the condition "f1 op f2", op may be any of the following relational operators:

O (One)
Expression is true if f1 contains 1 in the bit positions specified by f2.

Z (Zero)
Expression is true if f1 contains 0 in the bit positions specified by f2.

M (Mixed)
Expression is true if f1 contains 1 and 0 in at least one of the bit positions specified by f2.

A byte consists of two half bytes, each comprising four bits. The following table shows all the possible values of a half byte, presented as a bit string, together with the corresponding hexadecimal and decimal values.

Half byte Hexadecimal Decimal
  0000 , 0 0
  0001 , 1 1
  0010 , 2 2
  0011 , 3 3
  0100 , 4 4
  0101 , 5 5
  0110 , 6 6
  0111 , 7 7
  1000 , 8 8
  1001 , 9 9
  1010 , A 10
  1011 , B 11
  1100 , C 12
  1101 , D 13
  1110 , E 14
  1111 , F 15

Example: The byte '01101011' consists of the half bytes '0110' and '1011' and has the hexadecimal value '6B'.

Note

You can represent sets very well using bit sequences (see note for COMPUTE). The comparison "f1 0 f2" is equivalent to the set comparison "f2 is a subset of f1".

In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Unicode Changes

Additional help

Comparing Bit Sequences