Skip to content
BetterDL

OR operation

Also called: disjunction, logical OR, Boolean OR, Boolean sum, logical sum, OR operator, inclusive OR operation

The Boolean operation that gives 1 when at least one input is 1, and 0 only when all inputs are 0. Written A + B.

OR outputs 1 when at least one input is 1. It is 0 only when every input is 0.

Think of two switches side by side: closing either one, or both, lights the lamp.

OR is written with a plus sign, A + B, and an OR of literals is called a sum term. In discrete maths it is A ∨ B; in code, a || b.

The + sign is not addition:

  • = 1, not 2. OR only asks whether something is 1.
  • = 1 and = A (null and identity laws).
  • = A (idempotent law).

This is inclusive OR: it is 1 when both inputs are 1. The "one or the other but not both" version is exclusive OR, the XOR.

In hardware this is the or gate.

000
011
101
111

Worked example

Example

Counting the 1s of an OR

In the 16-row truth table of , how many rows are 1?

  1. 1.

    The OR is 0 only when A, B, C and D are all 0: row 0000.

  2. 2.

    Every other row has at least one 1.

  3. 3.

    So 16 − 1 = 15 rows are 1.

  4. 4.

    Counting the 0s is often quicker than counting the 1s.

Common mistakes

  • Writing 1 + 1 = 2, or 1 + 1 = 0 (that is XOR).

  • Reading everyday "or" as exclusive. Boolean OR includes the case where both inputs are 1.

Practice OR operation

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

OR operation is taught in Boolean Algebra and Logic Gates.