Code & Robots, level 8
🔢 Binary: Ones and Zeros
How can a computer store everything using only ones and zeros?
- How can a computer store everything using only ones and zeros? Deep inside every computer are billions of tiny electronic switches, and each switch can be in only two states, on or off, which people usually write as 1 and 0. A single 1 or 0 is called a bit, which is short for binary digit. By itself, one bit can only answer a single yes-or-no question, but when bits are lined up in a row, they can represent much more information. Two bits can make four different combinations, and three bits can make eight, because every additional bit doubles the number of possible patterns. A group of eight bits is called a byte, and a single byte can make 256 different patterns, enough to give every letter, digit and symbol on a keyboard its own code.
- Binary is a way of writing numbers using only two digits, 0 and 1. In the ordinary numbers you use every day, each place is worth ten times the place to its right, which gives you ones, tens and hundreds. In binary, each place is worth exactly two times the place to its right. Reading from right to left, the places are worth 1, 2, 4 and 8, and then 16, 32, 64 and 128. To figure out what a binary number represents, you add together the values of every place that contains a 1. For example, 101 has a 1 in the fours place and another in the ones place, so it represents 4 + 1, which equals 5. Similarly, the binary number 1010 represents 8 + 2, which equals 10.
- You can also convert an everyday number into binary. Begin with the largest place value that fits inside your number, and put a 1 in that place. Subtract that value, then move one place to the right, writing a 1 if the next value fits into what remains, or a 0 if it does not. Consider the number 6, where the fours place fits, so you write 1, leaving 2. The twos place fits as well, so you write another 1, leaving nothing. The ones place does not fit, so you write 0, which produces 110. In the same way, the number 9 contains one eight, no four, no two and one one, so it becomes 1001. Photographs, music and messages on a screen are all stored as enormous rows of bits like these, which a computer processes at amazing speed.
Try it at home: Hold up fingers as bits worth 1, 2, 4, 8 and 16 on one hand: take turns showing a number, and see who can work out the most numbers.
Questions and answers
Binary: Ones and Zeros
- A single 1 or 0 in a computer is called a… bit (A bit, short for binary digit, is a single 1 or 0.)
- 📦 How many bits are in one byte? 8 (A byte is a group of eight bits.)
- What number does the binary number 11 stand for? 3 (A 1 in the twos place and a 1 in the ones place make 2 plus 1, which is 3.)
- 💡 What number does the binary number 1000 stand for? 8 (The fourth place from the right is the eights place, so 1000 means 8.)
- What number does the binary number 111 stand for? 7 (4 plus 2 plus 1 is 7.)
- ✍️ How do you write the number 5 in binary? 101 (5 is one four and one one, so it is 1, 0, 1.)