Node:Truth tables and bit masks, Previous:Shift operations, Up:Machine-level operators



Truth tables and bit masks

The binary operators AND (&), OR (inclusive OR, |) and XOR (exclusive OR, also called EOR, ^) perform comparisons, or masking operations, between two bit strings. They are also binary operators in the sense that they take two operands. There is another operator called NOT (~) that is a unary operator; it takes only one operand.

These bitwise operations are best summarized by truth tables. Each truth table for a binary operator (that is, one with two operands), indicates what the result of the operation is for every possible combination of two bits.