Truth Table Generator

Enter a boolean expression and its variables to build the truth table.

Result

A B C | R --------- 0 0 0 | 0 0 0 1 | 0 0 1 0 | 1 0 1 1 | 0 1 0 0 | 1 1 0 1 | 0 1 1 0 | 1 1 1 1 | 0
3 variables
8 rows
Precedence used: NOT, then AND, then XOR, then OR (the usual order in programming languages). Some logic textbooks give AND and OR equal rank and read left to right, so write parentheses wherever the order matters.

How it is calculated

The tool accepts the variables A, B and C only (up to three), so a table has 2n rows: 2, 4 or 8. Write the expression with the words AND, OR, NOT, XOR or the symbols &, |, !, ^, plus parentheses; case does not matter. Precedence from strongest to weakest is NOT, then AND, then XOR, then OR, the usual order in programming languages, and the result repeats it in a note; some logic texts, OpenStax among them, rank AND and OR equally and read left to right, so parentheses are the way to be sure. With this order, A XOR B AND C means A XOR (B AND C) while A XOR B OR C means (A XOR B) OR C. If the variables box is empty, the tool uses whichever of A, B, C appear in the expression. Rows count up in binary with A as the leftmost, most significant bit, and the column R shows the result, 1 for true and 0 for false. The tool also reports the number of variables and rows. Any other letter, operator or symbol, or a syntax error such as an unmatched bracket, makes the tool return nothing.

Worked example

Expression (A OR B) AND NOT C with variables A, B, C gives 3 variables and 8 rows. The result is true only when at least one of A or B is true and C is false. Row 0 0 0: (false OR false) AND true = 0. Row 0 1 0: (false OR true) AND true = 1. Row 1 1 1: true AND false = 0. Reading R from top to bottom the table is 0, 0, 1, 0, 1, 0, 1, 0: the table shows 3 variables and 8 rows.

Try this example →

Common mistakes

  • Using a fourth variable or letters beyond A to C, such as X and Y. Only A, B and C are recognized, and an expression using other letters returns nothing.
  • Assuming XOR binds as tightly as AND or as loosely as OR. It sits between them: A XOR B AND C is A XOR (B AND C), but A XOR B OR C is (A XOR B) OR C. When in doubt, write the brackets you mean.
  • Using operators that are not supported, such as NAND, NOR, -> or =. Build them from AND, OR and NOT, for example NOT (A AND B) for NAND.
  • Reading the rows in the wrong order. A is the first column and changes slowest, so 0 0 1 means A false, B false, C true.
  • Leaving a bracket unclosed or putting two operators in a row, such as A AND OR B. A syntax error produces no table at all.

Sources

About this calculator

A truth table lists every possible combination of true/false values for a boolean expression's variables alongside the resulting output, giving a complete and unambiguous definition of the expression's logic — for n variables there are exactly 2^n rows, so a 3-variable expression (A, B, C) produces 8 rows covering every possible input state.

This generator evaluates expressions built from AND, OR, NOT and XOR (accepting either the words or the symbols &, |, !, ^) and fills in every combination automatically. Truth tables are the basic verification tool in digital logic design and computer engineering — used to check that a circuit or boolean condition behaves as intended, to simplify expressions with Karnaugh maps, and to prove logical equivalence between two different-looking expressions.

Was this helpful?

You can pick up to 3 reactions.

Note from the editors

The tool is handy for proving two expressions are the same: run each one and compare the R columns row by row. NOT (A AND B) and NOT A OR NOT B both give 1, 1, 1, 0 for the rows 00, 01, 10 and 11, which is De Morgan's law in action. Matching columns over every row is a full proof for up to three variables. Which simplification or equivalence are you trying to confirm?

Comments

  • Be the first to comment.

Popular calculators

All Calculators