Computing Library › Classical Logic Gates
Classical Logic Gates

OR Gate

The OR gate outputs 1 when at least one input is 1, implementing inclusive logical disjunction.

What it does

The OR gate implements inclusive disjunction. Its output is 1 if any input is 1, and 0 only when every input is 0. In words, at least one condition must hold.

Truth table

Kronos motion — when
ABA OR B
000
011
101
111

Algebraic form

OR is written as addition: A plus B, or A or B. It satisfies A OR 0 = A and the saturating identity A OR 1 = 1. Like AND it is commutative and associative. Note that this is inclusive OR; the exclusive variant is the XOR gate.

Relationship to AND

By De Morgan's laws, an OR of inputs equals a NAND-style combination: A OR B is the same as NOT(NOT A AND NOT B). This duality lets designers convert OR logic into AND logic and vice versa.

In code

python
out = a | b   # bitwise OR
out = a or b  # logical OR

Where it appears

With AND and NOT, OR completes a functionally complete set, so any logic function can be built from these three.