Computer science
Logic: AND, OR, NOT
Three little words that every computer chip is built from.
What you need first
You use logic every day: you go outside if it's warm AND not raining. You're happy if grandma OR grandpa calls. Computers do exactly the same, just with electricity instead of thoughts. Here you'll meet the three building blocks that every decision a computer makes is put together from.
True or false
In logic there are only two possibilities: a statement is true or it is false, with nothing in between. People often write 1 for true and 0 for false. With AND, OR, and NOT you can combine such statements. AND is only true if both parts are true. OR is true if at least one part is true. NOT takes just one input and flips it: true becomes false, false becomes true. When you put several operators together, brackets help just like in maths: whatever stands inside the brackets is worked out first.
| A | B | AND |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
1 AND 0 = 0
Truth tables
To make sure nothing gets forgotten, you write all possibilities into a . With two inputs there are four combinations: 0 and 0, 0 and 1, 1 and 0, 1 and 1. For AND, only the last row shows a 1, because only there are both inputs true. For OR, every row shows a 1 except the first, because only there is no input true.
This is what chips are made of
The amazing part: every computer chip consists of millions or even billions of tiny that recreate exactly these three operations with electricity. They are called gates. Power on means 1, power off means 0. If you combine AND, OR, and NOT cleverly, you can calculate, compare, and display images with them. Everything a computer does ultimately runs through these building blocks.
Exercises
0 of 6 solvedTime to try it yourself. You can't break anything, every attempt counts.
When is AND true?
1 stands for true, 0 for false. What is 1 AND 0?
What is 1 OR 0?
Match each operator to when it is true.
What does NOT do to a true statement?
The tiny circuits in a chip that recreate AND, OR and NOT with electricity are called ….
Where this leads