LearnTronics
Math
Start with the simplest numbers: 0 and 1
Before doing arithmetic with large numbers, fractions, formulas, or algebra, it helps to understand something very basic: the same quantity can be written in different number systems. The system tells us which digits are available and what each position in a number means.
What does “base” mean?
The base of a number system tells us how many different digit values are used before we move to the next place position.
The number system most people use every day is base 10, also called the decimal system. It uses ten digits:
After 9, there is no new single digit available, so we move one place to the left and write 10.
Each place in a base-10 number is worth ten times the place to its right:
| Thousands | Hundreds | Tens | Ones |
|---|---|---|---|
| 103 | 102 | 101 | 100 |
| 1000 | 100 | 10 | 1 |
For example, the decimal number 347 means:
Base 2: binary
The simplest positional number system uses only two digits:
This is base 2, usually called binary. After 1 there is no third digit available, so just as decimal moves from 9 to 10, binary moves from 1 to 10.
That does not mean binary can represent only two quantities. It means every place in the number can contain only one of those two digits.
Binary place values
In base 2, each place is worth two times the place to its right. The place values are powers of 2:
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
Notice that the rightmost position is still worth 1. Moving one place left doubles the value: 1, 2, 4, 8, 16, 32, 64, 128, and so on.
Reading a binary number
Take the binary number:
The small 2 simply tells us that the number is written in base 2.
| Binary digit | 1 | 0 | 1 | 1 |
|---|---|---|---|---|
| Place value | 8 | 4 | 2 | 1 |
| Contribution | 8 | 0 | 2 | 1 |
So 1011 in binary represents the same quantity as 11 in decimal.
Counting in binary
The pattern becomes clearer if we simply count upward.
| Decimal | Binary | What happened? |
|---|---|---|
| 0 | 0 | Starting value |
| 1 | 1 | Last available single binary digit |
| 2 | 10 | Move to the next place |
| 3 | 11 | Both 2 and 1 places are used |
| 4 | 100 | Move to the next place again |
| 5 | 101 | 4 + 1 |
| 6 | 110 | 4 + 2 |
| 7 | 111 | 4 + 2 + 1 |
| 8 | 1000 | Next power of two |
| 9 | 1001 | 8 + 1 |
| 10 | 1010 | 8 + 2 |
| 11 | 1011 | 8 + 2 + 1 |
| 12 | 1100 | 8 + 4 |
| 13 | 1101 | 8 + 4 + 1 |
| 14 | 1110 | 8 + 4 + 2 |
| 15 | 1111 | 8 + 4 + 2 + 1 |
| 16 | 10000 | Next power of two |
Turning binary into decimal
To convert a binary number to decimal, simply add the place values wherever the binary digit is 1. Ignore positions containing 0.
The place values are 32, 16, 8, 4, 2, 1.
| Binary | 1 | 1 | 0 | 1 | 0 | 1 |
|---|---|---|---|---|---|---|
| Place | 32 | 16 | 8 | 4 | 2 | 1 |
| Use it? | Yes | Yes | No | Yes | No | Yes |
Therefore:
Why electronics likes base 2
A physical electronic circuit can often distinguish two states very reliably: off or on, low or high, false or true. Those two states can be represented by the two binary digits:
| Binary | Logic | Possible electrical meaning |
|---|---|---|
| 0 | False | Low / off |
| 1 | True | High / on |
That is why the same 0 and 1 that appear in binary arithmetic also appear in digital logic. The mathematics of binary numbers and the TRUE/FALSE ideas used in logic fit together naturally.
A useful pattern to remember
| Power | Value |
|---|---|
| 20 | 1 |
| 21 | 2 |
| 22 | 4 |
| 23 | 8 |
| 24 | 16 |
| 25 | 32 |
| 26 | 64 |
| 27 | 128 |
| 28 | 256 |
| 210 | 1024 |
You do not need to memorize an enormous table, but becoming familiar with the first several powers of 2 makes later work with digital electronics much easier.