Skip to content
BetterDL

AND operation

Also called: conjunction, logical AND, Boolean AND, Boolean product, logical product, AND operator

The Boolean operation that gives 1 only when all of its inputs are 1. Written AB or A·B and called a product.

AND outputs 1 only when every input is 1. If any input is 0, the result is 0.

Think of two switches in series on one wire: the lamp lights only if both are closed.

AND is written like multiplication, AB or A·B, and it behaves like multiplying 0s and 1s: 1 · 1 = 1, and anything times 0 is 0. That is why an AND of literals is called a product term. In discrete maths it is written A ∧ B; in code, a && b.

Useful facts:

  • An AND of literals is 1 for exactly one combination of the variables it mentions. is 1 only when A = 1 and B = 0.
  • = A and = 0 (identity and null laws).
  • It works for any number of inputs: needs all four.

In hardware this is the and gate. Together with OR and NOT it can build any boolean function.

000
010
100
111

Worked example

Example

Picking out one input

Which product is 1 only when A = 0, B = 1 and C = 0?

  1. 1.

    A must be 0, so use , which is 1 when A = 0.

  2. 2.

    B must be 1, so use the plain literal B.

  3. 3.

    C must be 0, so use .

  4. 4.

    The product is . Check: A = 0, B = 1, C = 0 gives 1 · 1 · 1 = 1. Any other input makes at least one literal 0.

Common mistakes

  • Thinking AND is 1 when at least one input is 1. That is OR.

  • Counting a product as 1 when most of its literals are 1. One 0 is enough to make it 0.

Practice AND operation

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

Learn it step by step

AND operation is taught in Boolean Algebra and Logic Gates.