Binary Logic
Since computers can only understand binary which means they can only do operations in 1s and 0s. Logic gates can help with doing these operations and are the building blocks of computers.
Logic gates
There are a number of different Logic gates take in one or more input and produce a single output.
NOT
A not gate inverts an input. On a gate the small circle represents an inverted input.
Input A | Output |
---|---|
0 | 1 |
1 | 0 |
AND
An and gate checks if input A and B are true. If they are both true the output is true.
Input A | Input B | Output |
---|---|---|
0 | 0 | 0 |
1 | 0 | 0 |
0 | 1 | 0 |
1 | 1 | 1 |
NAND
A NAND gate checks if input A and B are true. If they are both true the output is false. In short its just an inverted AND gate.
Input A | Input B | Output |
---|---|---|
0 | 0 | 1 |
1 | 0 | 1 |
0 | 1 | 1 |
1 | 1 | 0 |
OR
An OR gate checks if either of the inputs are true then the output is true.
Input A | Input B | Output |
---|---|---|
0 | 0 | 0 |
1 | 0 | 1 |
0 | 1 | 1 |
1 | 1 | 1 |
NOR
A NOR gate is an inverted OR gate.
Input A | Input B | Output |
---|---|---|
0 | 0 | 1 |
1 | 0 | 0 |
0 | 1 | 0 |
1 | 1 | 0 |
XOR
An exclusive or only is true if one of the inputs is true but not both.
Input A | Input B | Output |
---|---|---|
0 | 0 | 0 |
1 | 0 | 1 |
0 | 1 | 1 |
1 | 1 | 0 |
Symbols
Sometimes symbols are used to show the logic gates. Here are some common symbols.