A truth table is a table that shows the outputs from the logical combination of inputs. The truth tables we shall look at here are in binary and they are widely used in computing and electronics to show the outputs from logic gates or propositions. Logic gates are the basis of electronic circuits, propositions are the basis of logical analysis.
The outcome of truth tables in binary is either true or false, which are usually represented by 1 and 0 respectively. A logical system in which the outcomes are either true or false is usually called Boolean logic after George Boole who devised it and who is considered one of the founders of computer science.
We will consider three truth tables here.
This truth table is quite simple: if the input is 0 the output is 1, if the input is 1 the output is 0.
| input | output |
| 0 | 1 |
| 1 | 0 |
The OR truth table needs at least 2 inputs. If either input is 1 then the output will be 1:
| input 1 | input 2 | output |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
An example OR condition in every day life might be: if I am hungry or thirsty then I will go to the shop.
Write out the truth table for this situation.
The AND truth table needs at least 2 inputs. Only if both inputs are 1 will the output be 1.
| input 1 | input 2 | output |
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
An example AND condition would be: if there is cake on the table and I am hungry then I will eat some cake.
Write out the truth table for this situation.
Construct truth tables for NOT, OR and AND in a spreadsheet. This will require use of the IF operator (though you could cheat and use NOT, AND and OR, all of which exist in Excel!)
The XOR truth table needs at least two inputs. The output is 0 if the inputs are the same - even two 1s produce output 0.
| input 1 | input 2 | output |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
XOR can be used to set a value to zero as any bit XORed with itself is 0 (0 XOR 0 = 0; 1 XOR 1 = 0). XOR is used in cryptography to encrypt data and data streams.