Binary System
The Computer's Language (Introduction to Binary)
Binary
Binary is a base-2 numbering system used by computers to represent data. It uses only two unique symbols: 0 and 1. While humans communicate with words and count with decimals, computers "speak" in binary.
Relate to a simple switch. You can either turn it off or on.
Why 2?
Because it maps directly onto the physical “on/off” states of electronic circuits: a wire is either carrying a high voltage (1) or a low voltage (0). This makes everything from arithmetic to logic to storage naturally expressed as sequences of bits (binary digits).
Example: If the voltage is low, either the light is on or off, their's no other middleground. In information systems that means, low noise. This is one of the distinct behaviour between quantum computers and classical computers.
Transistor is the switch in the modern hardware.
The Mathematical Foundation
Every digit in a binary number represents a specific power of 2. If we have a binary number, its value is calculated by multiplying the digit by the power of 2 corresponding to its position.
In general, for any position (counting from 0 on the right):
$$Value = Digit \times 2^{Position}$$
This means the place values grow exponentially: 1, 2, 4, 8, 16, 32...
Breaking Down a Number
Let's look at the binary number 1011. To understand its decimal value, we map it to the place value columns.
| Eights ($2^3$) | Fours ($2^2$) | Twos ($2^1$) | Ones ($2^0$) |
|---|---|---|---|
| 1 | 0 | 1 | 1 |
| 8 | 0 | 2 | 1 |
Calculation: $$ \begin{aligned} 1 \times 8 &= 8 \\ 0 \times 4 &= 0 \\ 1 \times 2 &= 2 \\ 1 \times 1 &= 1 \\ \text{Total} &= 8 + 0 + 2 + 1 = 11 \end{aligned} $$
So, the binary number 1011 is equal to the decimal number 11.
| Bit 2 (MSB) | Bit 1 | Bit 0 (LSB) | Binary | Decimal |
|---|---|---|---|---|
| 0 | 0 | 0 | 000 | 0 |
| 0 | 0 | 1 | 001 | 1 |
| 0 | 1 | 0 | 010 | 2 |
| 0 | 1 | 1 | 011 | 3 |
| 1 | 0 | 0 | 100 | 4 |
| 1 | 0 | 1 | 101 | 5 |
| 1 | 1 | 0 | 110 | 6 |
| 1 | 1 | 1 | 111 | 7 |
Don't get confused about MSB(Most Significant Bit) and LSB(Least Significant Bit) for now.
Bits
In the decimal system, we call each symbol a "digit." In the binary system, we call each symbol a bit (short for Binary digit).
- A single bit can be 0 or 1.
- A group of 8 bits is called a byte.
Because bits are so small, they are usually grouped together to represent larger numbers. An 8-bit byte can represent $2^8$ or 256 different values (0–255).
Why matters?
Deep down a computer is a machine checking billions of switches every second.
Every photo we take, every song we hear, and every letter we type is ultimately broken down into a sequence of 0s and 1s.