Logical operators act on the individual bits of ordinal expressions. Logical
operators require operands that are of an integer type, and produce an integer type result. The
possible logical operators are listed in table (6.4).
Table 6.4:
Logical operators
Operator
Operation
not
Bitwise negation (unary)
and
Bitwise and
or
Bitwise or
xor
Bitwise xor
shl
Bitwise shift to the left
shr
Bitwise shift to the right
The following are valid logical expressions:
A shr 1 { same as A div 2, but faster}
Not 1 { equals -2 }
Not 0 { equals -1 }
Not -1 { equals 0 }
B shl 2 { same as B * 2 for integers }
1 or 2 { equals 3 }
3 xor 1 { equals 2 }