Truth table

A truth table is just a way of us showing all the possible outputs of a logical operation (or logic gate) based on all the possible combinations of its inputs.

An example: AND

For example, let’s consider a simple logical operation called “AND”. The AND operation takes two inputs and produces an output that is “true” (or “1”) only if both inputs are “true” (or “1”). If either input is “false” (or “0”), the output is also “false” (or “0”).

If we list out all the possible combinations of inputs and their corresponding outputs, we get the following truth table for the AND operation:

Input AInput BOutput (A AND B)
000
010
100
111

In this table:

Interpreting truth tables

Let’s take the example from above:

Input AInput BOutput (A AND B)
000
010
100
111

So we can see that, for an AND gate to output a 1, both of its inputs must be 1.

Truth tables with only one input

Here’s an example of a truth table for a logical operation called “NOT”, which takes a single input and produces an output that is the opposite of the input.

It works in exactly the same way:

Input AOutput (NOT A)
01
10

How about 3 inputs?

Here’s a truth table for a logical operation which outputs a 1 if at least two of its three inputs are 1:

Input AInput BInput COutput
0000
0010
0100
0111
1000
1011
1101
1111

In this table, the output is 1 in the rows where at least two of the inputs are 1.

That’s all there is to truth tables! They’re just a simple way of showing how logical operations work based on their inputs.