8.5.7   Bit Operations

This section describes the operations for bit processing of numbers. The operands have to be integers.

Operation Meaning HALCON operator

lsh(i1,i2) left shift tuple_lsh
rsh(i1,i2) right shift tuple_rsh
i1 band i2 bitwise and tuple_band
i1 bxor i2 bitwise xor tuple_bxor
i1 bor i2 bitwise or tuple_bor
bnot i bitwise complement tuple_bnot

Table 8.12: Bit operations.

The result of lsh(i1,i2) is a bitwise left shift of i1 that is applied i2 times. If there is no overflow this is equivalent to a multiplication by 2i2. The result of rsh(i1,i2) is a bitwise right shift of i1 that is applied i2 times. For non-negative i1 this is equivalent to a division by 2i2. For negative i1 the result depends on the used hardware. For lsh and rsh the result is undefined if the second operand has a negative value or the value is larger than 32. More examples can be found in the program bit.hdev.