🔢 Math
💻 💻 Binary Converter: How Binary Numbers Work
Learn how binary numbers work and how to convert between binary, decimal, hex, and octal. Covers the base-2 system, place values, and why computers use binary.
⏱️ 8 min read🦉 365tool.net🌍 For everyone worldwide
Every digital device — your smartphone, laptop, smart TV, even a microwave with a digital timer — operates entirely on binary numbers. All images, text, audio, and video are ultimately stored and processed as sequences of 1s and 0s. Understanding binary is the foundation of understanding how computers actually work, and converting between number systems is a practical skill for anyone studying computer science, programming, or electronics.
The Binary (Base-2) Number System
Our everyday decimal system is base-10: it uses ten digits (0–9) and each position represents a power of 10.
Binary is base-2: it uses only two digits (0 and 1) and each position represents a power of 2.
Binary Place Values
| Position (from right) |
Power of 2 |
Decimal Value |
| 1st (rightmost) | 2⁰ | 1 |
| 2nd | 2¹ | 2 |
| 3rd | 2² | 4 |
| 4th | 2³ | 8 |
| 5th | 2⁴ | 16 |
| 6th | 2⁵ | 32 |
| 7th | 2⁶ | 64 |
| 8th | 2⁷ | 128 |
Binary to Decimal Conversion
Multiply each binary digit by its place value, then add:
Example: Convert binary 10110101 to decimal
Reading right to left: 1×1 + 0×2 + 1×4 + 0×8 + 1×16 + 1×32 + 0×64 + 1×128
= 1 + 0 + 4 + 0 + 16 + 32 + 0 + 128 = 181
Decimal to Binary Conversion
Repeatedly divide by 2, recording remainders. Read remainders bottom-to-top.
Example: Convert decimal 45 to binary
- 45 ÷ 2 = 22 remainder 1
- 22 ÷ 2 = 11 remainder 0
- 11 ÷ 2 = 5 remainder 1
- 5 ÷ 2 = 2 remainder 1
- 2 ÷ 2 = 1 remainder 0
- 1 ÷ 2 = 0 remainder 1
Read remainders bottom-to-top: 101101
Verify: 32+8+4+1 = 45 ✓
Hexadecimal (Base-16) — The Programmer's Shorthand
Binary is cumbersome to write — 8 binary digits represent values 0–255. Hexadecimal (base-16) groups 4 binary digits into a single hex digit, making binary data far more readable.
Hex digits: 0–9 (same as decimal), then A=10, B=11, C=12, D=13, E=14, F=15
Binary to Hex
Group binary digits into groups of 4 from the right, then convert each group:
Binary: 1101 1010 → D A → hex: DA → decimal: 218
Common Hex Values You'll See
- Color codes: #FF0000 (red), #00FF00 (green), #0000FF (blue), #FFFFFF (white), #000000 (black)
- Memory addresses: 0x7FFF FFFF (max 32-bit signed integer)
- Unicode characters: U+1F600 is the 😀 emoji
Octal (Base-8)
Groups binary into 3-bit chunks. Used in Unix/Linux file permissions:
chmod 755 means permissions 111 101 101 in binary = rwx r-x r-x (owner can read/write/execute, group and others can read/execute)
Why Computers Use Binary
Electronic components have two stable states — on and off, high and low voltage, magnetized and demagnetized. Representing these two states with 1 and 0 is natural and robust. Decimal would require 10 distinct voltage levels, which would be much harder to distinguish reliably. Binary's simplicity enables:
- Transistors: act as binary switches — on (1) or off (0)
- Logic gates: AND, OR, NOT operations on binary digits build all computation
- Error tolerance: a voltage of 3.8V is still clearly "high" even with electrical noise; no ambiguity as there would be with 10 levels
Bits and Bytes
- Bit: a single binary digit (0 or 1) — the smallest unit of data
- Byte: 8 bits → can represent 2⁸ = 256 different values (0–255)
- Kilobyte (KB): 1,024 bytes = 2¹⁰ bytes
- Megabyte (MB): 1,024 KB = 2²⁰ bytes (≈ 1 million bytes)
- Gigabyte (GB): 1,024 MB = 2³⁰ bytes (≈ 1 billion bytes)
A single character of ASCII text = 1 byte. A typical uncompressed photo = 3–6 MB (3–6 million bytes = 24–48 million binary digits).
❓ Frequently Asked Questions
How do you convert binary to decimal?▼
Multiply each binary digit by its place value (powers of 2 from right to left) and add the results. Binary 1011: (1×8) + (0×4) + (1×2) + (1×1) = 8+0+2+1 = 11. The rightmost position is 2⁰=1, next is 2¹=2, then 2²=4, 2³=8, and so on.
How do you convert decimal to binary?▼
Repeatedly divide the number by 2, recording the remainder each time. Then read the remainders from bottom to top. Example: 13 ÷ 2 = 6 r1; 6 ÷ 2 = 3 r0; 3 ÷ 2 = 1 r1; 1 ÷ 2 = 0 r1. Reading bottom-to-top: 1101. Verify: 8+4+0+1=13 ✓
Why do computers use binary instead of decimal?▼
Electronic components naturally have two stable states — on/off, high/low voltage. Binary maps perfectly to these two states. Using decimal would require 10 distinguishable voltage levels, which would be unreliable with electrical noise. Binary's simplicity makes it extremely noise-tolerant and allows billions of reliable transistor switches in a modern chip.
What is hexadecimal and how does it relate to binary?▼
Hexadecimal (base-16) uses digits 0–9 and A–F (where A=10, B=11, C=12, D=13, E=14, F=15). Each hex digit represents exactly 4 binary digits, making it a compact shorthand. Binary 1111 1010 = FA in hex. Web color codes like #FF8800 (orange) are hex: FF=red, 88=green, 00=blue.
What is a byte?▼
A byte is 8 binary digits (bits). With 8 bits, you can represent 2⁸ = 256 different values (0 to 255). One byte can store one ASCII text character. Storage sizes — kilobytes (1,024 bytes), megabytes (1,024 KB), gigabytes (1,024 MB) — are all measured in multiples of bytes, reflecting the binary base-2 nature of computer memory.