Understanding Number Systems
Number systems are methods for representing quantities using symbols called digits. The most common number system in daily life is decimal (base 10), but computers and programmers frequently work with binary (base 2), hexadecimal (base 16), and octal (base 8). Each system has unique advantages for different applications.
The binary converter above instantly converts between all four major number systems. Simply select your input type, enter the value, and see the equivalent representations in all formats. The converter updates live as you type, making it easy to explore relationships between different bases.
The Four Major Number Systems
Binary (Base 2)
Digits: 0, 1
The fundamental language of computers. Every digital device processes information as sequences of 0s and 1s, representing off and on states of electronic switches. Each digit is called a "bit" (binary digit).
Decimal (Base 10)
Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
The everyday number system humans use. Its prevalence likely stems from our ten fingers. Each position represents a power of 10 (ones, tens, hundreds, thousands, etc.).
Hexadecimal (Base 16)
Digits: 0-9, A, B, C, D, E, F
Widely used in computing because it compactly represents binary data. Each hex digit corresponds to exactly 4 binary bits, making conversion straightforward. Colors in web design (like #FF5733), memory addresses, and MAC addresses use hexadecimal.
Octal (Base 8)
Digits: 0, 1, 2, 3, 4, 5, 6, 7
Each octal digit represents exactly 3 binary bits. Historically important in computing (Unix file permissions still use octal), though hexadecimal is now more common for most applications.
Conversion Reference Table
| Decimal | Binary | Hex | Octal |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 5 | 0101 | 5 | 5 |
| 10 | 1010 | A | 12 |
| 15 | 1111 | F | 17 |
| 16 | 1 0000 | 10 | 20 |
| 100 | 110 0100 | 64 | 144 |
| 255 | 1111 1111 | FF | 377 |
| 256 | 1 0000 0000 | 100 | 400 |
How to Convert Between Number Systems
Decimal to Binary
Divide the number by 2 repeatedly, recording the remainder at each step. Read the remainders from bottom to top.
Example: Convert 42 to binary
42 ÷ 2 = 21 remainder 0
21 ÷ 2 = 10 remainder 1
10 ÷ 2 = 5 remainder 0
5 ÷ 2 = 2 remainder 1
2 ÷ 2 = 1 remainder 0
1 ÷ 2 = 0 remainder 1
Reading bottom to top: 42 = 101010 in binary
Binary to Decimal
Multiply each bit by its position value (powers of 2) and sum the results.
Example: Convert 101010 to decimal
1×2⁵ + 0×2⁴ + 1×2³ + 0×2² + 1×2¹ + 0×2⁰
= 32 + 0 + 8 + 0 + 2 + 0
= 42
Binary to Hexadecimal
Group binary digits into sets of 4 (from right), then convert each group to its hex equivalent.
Example: Convert 11010110 to hex
Group: 1101 | 0110
1101 = 13 = D
0110 = 6 = 6
Result: D6
Applications in Computing
Memory Addresses
Computer memory locations are typically expressed in hexadecimal because it's compact yet directly relates to the underlying binary. A 32-bit address like 0x7FFF0000 is much easier to read than its binary equivalent.
Color Codes
Web colors use 6-digit hexadecimal codes representing RGB values. Each pair of digits (00-FF) represents an intensity from 0-255 for red, green, and blue:
- #FF0000 = Pure red (255, 0, 0)
- #00FF00 = Pure green (0, 255, 0)
- #0000FF = Pure blue (0, 0, 255)
- #FFFFFF = White (255, 255, 255)
- #000000 = Black (0, 0, 0)
File Permissions (Unix/Linux)
Octal notation represents file permissions where each digit encodes read (4), write (2), and execute (1) permissions:
- chmod 755 = rwxr-xr-x (owner: all, others: read+execute)
- chmod 644 = rw-r--r-- (owner: read+write, others: read only)
- chmod 777 = rwxrwxrwx (all permissions for everyone)
Network Addresses
IP addresses and subnet masks are often analyzed in binary form to understand network routing. MAC addresses use hexadecimal notation (e.g., 00:1A:2B:3C:4D:5E).
Binary Arithmetic
Addition
Binary addition follows simple rules: 0+0=0, 0+1=1, 1+0=1, 1+1=10 (carry the 1).
Powers of 2
Understanding powers of 2 is essential for binary work:
| 2ⁿ | Value | Common Name |
|---|---|---|
| 2⁰ | 1 | - |
| 2⁸ | 256 | Byte range |
| 2¹⁰ | 1,024 | 1 KB (Kilobyte) |
| 2¹⁶ | 65,536 | 16-bit range |
| 2²⁰ | 1,048,576 | 1 MB (Megabyte) |
| 2³⁰ | 1,073,741,824 | 1 GB (Gigabyte) |
| 2³² | 4,294,967,296 | 32-bit range |
Frequently Asked Questions
Why do computers use binary?
Computer circuits have two stable states: on and off (represented by voltage levels). Binary (0 and 1) directly maps to these physical states, making it the natural choice for digital electronics. Higher bases would require circuits that distinguish between more voltage levels, increasing complexity and error rates.
What does 0x mean before a number?
The "0x" prefix indicates hexadecimal notation in many programming languages (C, Java, Python, JavaScript). Similarly, "0b" often indicates binary, and "0o" indicates octal.
How many bits are in common data sizes?
A byte is 8 bits. A word is typically 16, 32, or 64 bits depending on the processor architecture. Modern computers are mostly 64-bit, meaning they process data in 64-bit chunks.
Why is hexadecimal popular in programming?
Each hex digit represents exactly 4 bits, so a byte (8 bits) is always 2 hex digits. This makes hex very convenient for representing binary data compactly while maintaining easy mental conversion to binary.