Binary Numbers
A World With Two Symbols
Deep inside every computer there are billions of microscopic switches. Each switch is either on or off β nothing in between. Two states is all the hardware can reliably offer, so computing needed a number system with just two digits.
That system is binary (base 2). Its digits are 0 (off) and 1 (on), and one binary digit is called a bit.
Place Value β Doubling Instead of Tens
You already know decimal place value: each column is worth 10 times the one to its right (β¦1000, 100, 10, 1).
Binary works identically, except each column is worth 2 times the one to its right:
place value: 8 4 2 1
binary: 1 1 0 1
β β β β
8 + 4 + 0 + 1 = 13
So binary 1101 is decimal 13. That is the entire trick β same place-value idea you learned in primary school, different multiplier.
Binary to Decimal
Write the place values above the bits, then add up the columns with a 1:
| 8 | 4 | 2 | 1 | Decimal |
|---|---|---|---|---|
| 0 | 1 | 0 | 1 | 4 + 1 = 5 |
| 1 | 0 | 1 | 0 | 8 + 2 = 10 |
| 1 | 1 | 1 | 1 | 8 + 4 + 2 + 1 = 15 |
Note the last row: 1111 = 15 is the biggest value 4 bits can hold. Counting from 0, that gives 16 different values β with n bits you get 2βΏ values.
Decimal to Binary
To convert decimal to binary, take the biggest place value that fits, subtract, and repeat:
Convert 6:
- Does 8 fit in 6? No β write 0
- Does 4 fit in 6? Yes β write 1, and 6 β 4 = 2 left
- Does 2 fit in 2? Yes β write 1, and 2 β 2 = 0 left
- Does 1 fit in 0? No β write 0
Result: 0110, or just 110. Check it: 4 + 2 = 6 β
Bits, Bytes, and Big Files
- 1 bit β a single 0 or 1
- 1 byte β 8 bits, enough for one character of text
- 1 kilobyte (KB) β about a thousand bytes
- 1 megabyte (MB) β about a million bytes (a minute of music)
- 1 gigabyte (GB) β about a billion bytes (hundreds of photos)
Those storage numbers on phones suddenly mean something: a 64 GB phone holds roughly half a trillion bits β half a trillion tiny switches set on or off.
Everything Is Numbers
Here is the deep idea, and it connects straight back to abstraction: computers store only binary numbers, yet show us text, photos, and songs. How?
- Text β every character gets an agreed number code (in one common code, A is 65, B is 66β¦), and the numbers are stored in binary
- Images β the picture is a grid of pixels; each pixel's colour is a set of numbers
- Sound β the sound wave is measured thousands of times per second; each measurement is a number
Layer by layer, numbers become letters, pixels, and music. When you input anything into a computer β a keypress, a photo, your voice β the very first step is always the same: turn it into binary.
Worked Example β Converting a Bigger Number
The subtract-the-biggest-place-value method scales easily to numbers larger than the 4-bit examples above. Convert decimal 83 to binary using place values 128, 64, 32, 16, 8, 4, 2, 1:
| Place value | Does it fit? | Bit | Remaining |
|---|---|---|---|
| 128 | No | 0 | 83 |
| 64 | Yes | 1 | 83 β 64 = 19 |
| 32 | No | 0 | 19 |
| 16 | Yes | 1 | 19 β 16 = 3 |
| 8 | No | 0 | 3 |
| 4 | No | 0 | 3 |
| 2 | Yes | 1 | 3 β 2 = 1 |
| 1 | Yes | 1 | 1 β 1 = 0 |
Reading the bits column top to bottom: 01010011. Check it by converting back: 64 + 16 + 2 + 1 = 83 β. Notice this used exactly 8 bits β one byte β which is no coincidence: a single byte holds values from 0 to 255, comfortably covering 83, and this is exactly the size used to store one ASCII character or one colour channel value in an image.
Binary Addition β Just Like Decimal, With Carrying
Binary numbers can be added using the same column-by-column method as decimal addition, just with only two digits instead of ten. The rules: 0+0=0, 0+1=1, 1+1=10 (write 0, carry 1), and 1+1+1 (with an incoming carry)=11 (write 1, carry 1).
1 1 β carries
0 1 1 0 (6)
+ 0 1 0 1 (5)
βββββββββ
1 0 1 1 (11)
Working right to left: 0+1=1 (no carry). 1+0=1 (no carry). 1+1=10, write 0 carry 1. 0+0+1(carry)=1. Result: 1011, which is 8+2+1=11 in decimal β and 6+5 is indeed 11. This is exactly the mechanism a logic-gate circuit called an adder performs electronically, at billions of additions per second, using the same carrying rule you just did by hand.
Key Words
- Binary β the base-2 number system using only 0 and 1
- Bit β one binary digit
- Byte β a group of 8 bits
- Place value β the worth of each column; in binary it doubles: 1, 2, 4, 8, β¦
- Pixel β one dot of an image, whose colour is stored as numbers
Questions & comments
Comments are public and are checked before they appear. Please donβt post your full name, email, phone number, school, or anything else that identifies you. How we use this.
Loading commentsβ¦