Binary operators also work on bit strings, as shown in the table below.

Table 4-10. Bit String Operators

Example Result
B'10001' & B'01101' 00001
B'10001' | B'01101' 11101
B'10001' # B'01101' 11110
~B'10001' 01110
B'10001' << 3 01000
B'10001' >> 2 00100
Note Shifting Bit Strings
 

When shifting bit strings, the original length of the string does not change.

Also, when using operators such as &, |, and #, the bit strings within the argument must be of equal length.