What Is the OR Logic Gate?
The OR gate is one of the fundamental logic gates in digital electronics. It produces an output of 1 (true) if at least one of its inputs is 1. The output is 0 (false) only when all inputs are 0. In Boolean algebra, the OR operation is represented by the symbol "+" or "v".
OR Gate Truth Table
0 OR 0 = 0
Both inputs are false, output is false.
0 OR 1 = 1
One input is true, output is true.
1 OR 0 = 1
One input is true, output is true.
1 OR 1 = 1
Both inputs are true, output is true.
Bitwise OR Operations
When performing OR on multi-bit binary numbers, the operation is applied bit by bit (bitwise). Each pair of corresponding bits from the two inputs is compared independently. This is used extensively in computer programming for setting specific bits in a bitmask, combining flags, and manipulating data at the bit level.
Properties of OR
- Commutative: A OR B = B OR A
- Associative: (A OR B) OR C = A OR (B OR C)
- Identity: A OR 0 = A
- Idempotent: A OR A = A
- Annihilation: A OR 1 = 1
- De Morgan's Law: NOT(A OR B) = (NOT A) AND (NOT B)
Applications
OR gates are used in digital circuits for signal routing, interrupt handling, and building more complex logic circuits. In programming, the bitwise OR operator (| in most languages) is used for combining permission flags, creating bitmasks, and implementing set union operations on bit vectors.