The computer's language: 0 and 1
๐ In short
We write numbers with ten digits, 0 to 9. But a computer only knows two: 0 and 1! Inside it are millions of tiny electric switches, each either off (0) or on (1). And with just these two digits the computer writes every number, letter, picture and sound.
๐คฉ Did you know?
- A single place (0 or 1) is called a โbitโ, and eight places together are called a โbyteโ.
- With just five fingers you can count in binary from 0 to 31!
- A single photo from your phone has millions of pixels, and each pixel's color is stored as numbers.
- In binary, 10 doesn't mean ten, it means two!
๐ Find out more
๐ Why only two digits?
It's very easy for a machine to tell whether electricity is flowing or not: yes or no, on or off. So engineers chose a system with just two states, called the โbinary systemโ.
๐ How do we count with 0 and 1?
In binary, each place is worth double the place to its right: 1, then 2, then 4, then 8, then 16. So the number 5 is written 101, because 4 + 1 = 5, and the number 3 is written 11, because 2 + 1 = 3.
๐ก What about letters?
Every letter has its own number in a table all computers agree on. When you type the letter โbโ, the computer stores it as a number, a string of 0s and 1s, then draws it on the screen again when you need it.
๐ฏ And pictures?
A picture on the screen is made of tiny squares called โpixelsโ. The computer stores each square's color as numbers. For a black-and-white picture, we just write 1 for a black square and 0 for a white one!
๐งญ Letters as numbers
The computer stores the letter A as the number 65, or 01000001. Arabic letters have numbers too, in a worldwide table called โUnicodeโ that holds the letters of every language in the world, and even smiley faces.
๐ Bits and bytes
One place is a bit, and eight places make a byte. One byte can write a number from 0 to 255, which is why we often see 255 in the computer world, like the strength of screen colors.
๐ See how it works
๐ Key words
- Bit
- A single place holding 0 or 1
- Byte
- Eight places together
- Unicode
- A worldwide table giving a number to every letter in every language
๐งช Try it at home
Count in binary on your fingers: thumb 1, index finger 2, middle finger 4, ring finger 8 and little finger 16. Raise a finger to write 1. How many numbers can you write with one hand? (Answer: 0 to 31!)
๐งฉ Test yourself
1 Which two digits does a computer use?
2 How is the number 3 written in binary?
3 What do we call the tiny squares a picture is made of?