How Does Binary Work- Computer Number System
What the Heck Is Binary, Anyway?
Binary is a number system that uses only two digits: 0 and 1. That's it. No 2s, no 3s, no fancy symbols. Just off and on, true and false, yes and no.
Your computer runs on binary. Every pixel on your screen, every letter you type, every video you watch—all of it comes down to sequences of 0s and 1s. If you want to understand how computers actually work under the hood, binary is where you start.
Why Computers Use Binary (And Not Something Smarter)
Humans use decimal (base-10) because we have ten fingers. Computers don't have fingers. They have electrical circuits that are either on or off.
One circuit = two states. That's binary.
It's not that binary is the best number system. It's that it's the easiest to implement with hardware. Transistors—tiny switches inside processors—can only really handle two states reliably. Trying to build a computer around ten different voltage levels would be a nightmare of interference and errors.
Binary is a physical constraint, not a philosophical choice.
Breaking Down Binary: Bits and Bytes
Here's the vocabulary you need:
- Bit — A single binary digit (0 or 1). Short for "binary digit."
- Byte — Eight bits grouped together. One byte can represent 256 different values (2⁸).
- Kilobyte (KB) — 1,024 bytes (historically; marketing uses 1,000).
- Megabyte (MB) — 1,024 kilobytes.
- Gigabyte (GB) — 1,024 megabytes.
When someone says "8-bit," they mean values stored in 8 bits. That's why old game consoles like the NES were called "8-bit"—their processors handled data in 8-bit chunks.
How Binary Numbers Actually Work
Decimal uses positional values based on powers of 10:
543 = (5 × 100) + (4 × 10) + (3 × 1)
Binary does the same thing, but with powers of 2:
Each position in a binary number represents a power of 2, starting from the right:
- 2⁰ = 1
- 2¹ = 2
- 2² = 4
- 2³ = 8
- 2⁴ = 16
- 2⁵ = 32
- 2⁶ = 64
- 2⁷ = 128
So the binary number 11010 breaks down like this:
| Position | 5 | 4 | 3 | 2 | 1 |
|---|---|---|---|---|---|
| Power of 2 | 2⁴ (16) | 2³ (8) | 2² (4) | 2¹ (2) | 2⁰ (1) |
| Binary Digit | 1 | 1 | 0 | 1 | 0 |
| Value | 16 | 8 | 0 | 2 | 0 |
16 + 8 + 0 + 2 + 0 = 26
The leftmost bit is the most significant bit (MSB). The rightmost is the least significant bit (LSB). This matters when you're doing bitwise operations or debugging low-level code.
Converting Decimal to Binary
Here's the straightforward method: divide by 2, keep track of remainders.
Let's convert 47 to binary:
- 47 ÷ 2 = 23 remainder 1
- 23 ÷ 2 = 11 remainder 1
- 11 ÷ 2 = 5 remainder 1
- 5 ÷ 2 = 2 remainder 1
- 2 ÷ 2 = 1 remainder 0
- 1 ÷ 2 = 0 remainder 1
Read the remainders from bottom to top: 101111
Verify: 32 + 16 + 4 + 2 + 1 = 55. Wait—that's wrong. Let me redo this.
Actually: 47 ÷ 2 = 23 r1, 23 ÷ 2 = 11 r1, 11 ÷ 2 = 5 r1, 5 ÷ 2 = 2 r1, 2 ÷ 2 = 1 r0, 1 ÷ 2 = 0 r1. Bottom to top: 101111.
Check: 1(32) + 0(16) + 1(8) + 1(4) + 1(2) + 1(1) = 32 + 8 + 4 + 2 + 1 = 47. Correct.
Converting Binary to Decimal
This one's easier. Just add up the values where there's a 1.
What is 100101 in decimal?
1(32) + 0(16) + 0(4) + 1(2) + 0(1) = 32 + 4 + 2 = 38
Most programmers memorize the powers of 2 up to 2¹⁰ (1024). It comes up constantly.
Binary and Text: ASCII
Numbers are one thing. But what about letters?
ASCII assigns a number to each character. 'A' is 65. 'a' is 97. '0' (the digit) is 48.
65 in binary is 1000001. That's 7 bits. Early computers used 7-bit ASCII, which gave you 128 characters. Modern systems use UTF-8, which can use up to 4 bytes per character, but ASCII is still the foundation.
When you type "Hello" into a text editor, your computer stores the binary equivalent of 72, 101, 108, 108, 111.
Hexadecimal: The Shortcut
Binary gets long fast. A 32-bit number is 32 digits. Nobody wants to read that.
Hexadecimal (base-16) exists to make binary readable. One hex digit represents four binary digits.
| Decimal | Binary | Hex |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 10 | 1010 | A |
| 15 | 1111 | F |
| 255 | 11111111 | FF |
You'll see hex everywhere: color codes (#FF5733), memory addresses, debug output. If you work with code, you need to be comfortable with hex.
Binary Arithmetic: It Works, But It's Ugly
Addition works the same as decimal, just with different digits:
1011 (11) + 1101 (13) = 11000 (24)
1 + 1 = 0, carry 1. When the carry overflows past the most significant bit, you get overflow—a real problem in fixed-width systems. If you're storing numbers in 8 bits and you add 150 + 150, you get garbage.
Subtraction, multiplication, division—all work, but nobody does this by hand anymore. Compilers and CPUs handle it.
Getting Started: Read Binary in 30 Seconds
Here's a practical skill: reading binary values quickly.
Ignore leading zeros. Focus on the rightmost 1. That's your minimum value.
Example: 00110100
Drop the leading zeros: 110100
Values: 32 + 16 + 4 = 52
That's the letter '4' in ASCII. Now you know how to decode basic binary without a calculator.
What You Should Take Away
Binary isn't complicated. It's just a different way of counting. Computers use it because physical circuits are easiest to build with two states. Everything else—text, images, video—is encoded on top of binary.
You don't need to do binary math by hand. But you should understand why it exists, what bits and bytes mean, and how to convert small numbers. That foundation makes everything else in computing make sense.