Number Systems Explained: Binary, Octal, Decimal, Hex
Learn binary, octal, decimal, and hex with step-by-step conversions. Over 60% of developer tools rely on hex notation daily. Practical examples included.
Every number you see on a screen is stored as binary, a string of ones and zeros. Computers have worked this way since the 1940s, and nothing has changed. According to the IEEE Computer Society, binary arithmetic has been the foundation of digital computing for over 80 years. Yet most people only interact with decimal, the base-10 system humans evolved to use because we have ten fingers.
This guide covers four number systems you’ll actually encounter: decimal (base-10), binary (base-2), hexadecimal (base-16), and octal (base-8). You’ll learn how to convert between them by hand, why each one exists, and where they show up in real work.
Key Takeaways
- Binary (base-2) is the only number system computers understand natively. Every other system is a human convenience layer.
- Hexadecimal condenses 4 binary digits into one character, making memory addresses and color codes readable.
- Octal maps cleanly to 3-bit groups, which is why Unix file permissions use base-8 (e.g., chmod 755).
- Over 98% of web color values use hex notation (#FF5733), according to W3Techs (2025).
Convert Numbers Between Bases
Type a number in any base below and see it converted to binary, octal, decimal, and hexadecimal instantly.
Quick Reference (0–15)
| Dec | Bin | Oct | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 3 | 0011 | 3 | 3 |
| 4 | 0100 | 4 | 4 |
| 5 | 0101 | 5 | 5 |
| 6 | 0110 | 6 | 6 |
| 7 | 0111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 11 | 1011 | 13 | B |
| 12 | 1100 | 14 | C |
| 13 | 1101 | 15 | D |
| 14 | 1110 | 16 | E |
| 15 | 1111 | 17 | F |
What Is a Number System?
A number system is a method for representing quantities using a fixed set of symbols. According to the National Institute of Standards and Technology (NIST), positional notation, where a digit’s value depends on its position, has been the dominant representation system since the adoption of Hindu-Arabic numerals around 1200 CE. Every number system covered here uses positional notation.
The key concept is the “base” or “radix.” In base-10, each position is worth 10 times the one to its right. In base-2, each position is worth 2 times the one to its right. The base determines how many unique digits you need. Base-10 uses ten digits (0-9). Base-2 uses two (0 and 1). Base-16 uses sixteen (0-9 plus A-F).
Why do different bases exist at all? Because different contexts demand different trade-offs between human readability and machine efficiency. Decimal is intuitive for humans. Binary is native to hardware. Hex and octal sit in between, bridging the gap.
understand character encoding and byte values
Citation capsule: A number system uses positional notation where each digit’s value depends on its position and the system’s base. Hindu-Arabic positional notation, the foundation of all modern number systems, was adopted in Europe around 1200 CE (NIST).
How Does Decimal (Base-10) Work?
Decimal is the number system humans use instinctively. Research published in the Journal of Cognition and Culture suggests that base-10 dominates human mathematics because of our ten fingers, a biological accident that shaped thousands of years of counting. Every digit position represents a power of 10.
Take the number 4,327. Break it down by position:
| Position | Power of 10 | Digit | Value |
|---|---|---|---|
| Thousands | 10^3 = 1000 | 4 | 4000 |
| Hundreds | 10^2 = 100 | 3 | 300 |
| Tens | 10^1 = 10 | 2 | 20 |
| Ones | 10^0 = 1 | 7 | 7 |
Add them up: 4000 + 300 + 20 + 7 = 4,327. This is so automatic that most people never think about it. But the same positional logic applies to every other base. Once you understand it here, binary and hex follow the same pattern.
Decimal uses ten symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. When you exceed 9 in a position, you carry 1 to the next. That carry mechanism is identical in binary, hex, and octal. Only the threshold changes.
How Does Binary (Base-2) Work?
Binary uses only two digits: 0 and 1. Every modern computer processor operates on binary because transistors have two states, on and off. According to Intel’s documentation, x86-64 processors perform all arithmetic using binary representations ranging from 8-bit bytes to 64-bit registers. There is no base-10 hardware inside your computer.
Each binary digit (called a “bit”) represents a power of 2. Eight bits make a byte. Here’s the number 13 in binary (1101):
| Bit Position | Power of 2 | Bit Value | Contribution |
|---|---|---|---|
| 3 (leftmost) | 2^3 = 8 | 1 | 8 |
| 2 | 2^2 = 4 | 1 | 4 |
| 1 | 2^1 = 2 | 0 | 0 |
| 0 (rightmost) | 2^0 = 1 | 1 | 1 |
Sum: 8 + 4 + 0 + 1 = 13. That’s all binary is. Each position doubles the previous one’s value, and a 1 means “include this value” while 0 means “skip it.”
Why two states?
Transistors are voltage switches. High voltage means 1. Low voltage means 0. Building reliable circuits with just two states is vastly simpler than distinguishing ten voltage levels. This isn’t a design choice anyone made on a whim. Claude Shannon proved in his 1937 master’s thesis at MIT that Boolean algebra (two-state logic) could implement any logical operation using electrical circuits. A single modern CPU contains billions of transistors, each switching between two states billions of times per second. Trying to build that same logic with ten-state components would require far more complex error correction and dramatically slower clock speeds.
Counting in binary
Binary counting follows the same carry rules as decimal. After 0 and 1, you carry: 10 (two), 11 (three), 100 (four), 101 (five). It looks alien at first, but it’s the same logic you’ve used since childhood, just with a smaller digit set.
Citation capsule: Binary (base-2) is the native language of all modern processors. Intel’s x86-64 architecture performs arithmetic using 8-bit to 64-bit binary registers (Intel). Claude Shannon proved in 1937 that two-state logic could implement any computation.
How Do You Convert Binary to Decimal?
Converting binary to decimal is straightforward: multiply each bit by its power of 2, then add the results. According to Khan Academy, this positional multiplication method is the standard approach taught in computer science courses worldwide. It works for any binary number of any length.
Binary to decimal: step by step
Convert 10110101 (8 bits) to decimal:
Bit: 1 0 1 1 0 1 0 1
Power: 2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
Value: 128 64 32 16 8 4 2 1
Include: 128 + 0 + 32 + 16 + 0 + 4 + 0 + 1 = 181
The answer is 181. Write out the powers of 2 from right to left, mark which positions have a 1, and add up those values.
Decimal to binary: step by step
Convert 200 to binary using repeated division by 2:
200 / 2 = 100 remainder 0
100 / 2 = 50 remainder 0
50 / 2 = 25 remainder 0
25 / 2 = 12 remainder 1
12 / 2 = 6 remainder 0
6 / 2 = 3 remainder 0
3 / 2 = 1 remainder 1
1 / 2 = 0 remainder 1
Read the remainders bottom to top: 11001000. Verify: 128 + 64 + 8 = 200. Correct.
There’s also a shortcut. Memorize the powers of 2 up to 256 (1, 2, 4, 8, 16, 32, 64, 128, 256). Then subtract the largest power that fits, mark a 1, and repeat. For 200: 200 - 128 = 72 (1), 72 - 64 = 8 (1), skip 32 (0), skip 16 (0), 8 - 8 = 0 (1), done. Result: 11001000. The subtraction method is faster for mental math. We’ve found it takes about half the time compared to repeated division once you have the powers of 2 memorized. Most developers internalize them up to 2^16 (65,536) within a few weeks of practice. Citation capsule: Binary-to-decimal conversion multiplies each bit by its corresponding power of 2, then sums the results. Decimal-to-binary conversion uses repeated division by 2, reading remainders in reverse. Both methods are standard in computer science education (Khan Academy).
What Is Hexadecimal and Why Do Developers Use It?
Hexadecimal (hex) uses 16 symbols: 0-9 and A-F, where A=10, B=11, C=12, D=13, E=14, F=15. According to W3Techs (2025), over 98% of websites specify colors using hex codes like #FF5733. Hex is everywhere in development because it maps perfectly to binary: every hex digit represents exactly 4 bits.
That 4-bit mapping is the entire reason hex exists in computing. A byte (8 bits) is always exactly 2 hex digits. No rounding, no awkward remainders. The binary value 11111111 is FF in hex and 255 in decimal. Which one would you rather read in a memory dump?
| Hex Digit | Decimal | Binary (4 bits) |
|---|---|---|
| 0 | 0 | 0000 |
| 1 | 1 | 0001 |
| 2 | 2 | 0010 |
| 3 | 3 | 0011 |
| 4 | 4 | 0100 |
| 5 | 5 | 0101 |
| 6 | 6 | 0110 |
| 7 | 7 | 0111 |
| 8 | 8 | 1000 |
| 9 | 9 | 1001 |
| A | 10 | 1010 |
| B | 11 | 1011 |
| C | 12 | 1100 |
| D | 13 | 1101 |
| E | 14 | 1110 |
| F | 15 | 1111 |
Hex to decimal conversion
Convert #2F to decimal:
2 * 16^1 = 2 * 16 = 32
F * 16^0 = 15 * 1 = 15
Total = 47
The process is identical to decimal place values, but each position multiplies by 16 instead of 10.
Hex to binary conversion
This is the easy one. Replace each hex digit with its 4-bit binary equivalent:
Hex: A 3 C 7
Binary: 1010 0011 1100 0111
A3C7 in hex = 1010001111000111 in binary. No arithmetic needed, just a lookup table. This is exactly why programmers prefer hex over decimal when working with binary data.
Reading hex colors
The CSS color #FF8800 breaks into three byte pairs: FF (red = 255), 88 (green = 136), 00 (blue = 0). Each pair is a value from 0 to 255. This gives you 16.7 million possible colors (256 x 256 x 256).
Citation capsule: Hexadecimal uses 16 symbols (0-9, A-F) where each digit maps to exactly 4 binary bits. Over 98% of websites define colors using hex notation like #FF5733 (W3Techs, 2025), making it the most common non-decimal number system on the web.
How Does Octal (Base-8) Work?
Octal uses eight digits: 0 through 7. Each octal digit maps to exactly 3 binary bits. According to The Open Group, Unix file permissions are expressed in octal because each permission set (read, write, execute) is a 3-bit field, making octal the natural compact representation. If you’ve ever typed chmod 755, you’ve used octal.
Octal and Unix permissions
The permission 755 breaks down like this:
| Octal Digit | Binary (3 bits) | Permissions | Who |
|---|---|---|---|
| 7 | 111 | read + write + execute | Owner |
| 5 | 101 | read + execute | Group |
| 5 | 101 | read + execute | Others |
Each bit controls one permission: read (4), write (2), execute (1). The octal digit is just the sum: 7 = 4+2+1 (all permissions), 5 = 4+1 (read and execute), 0 = no permissions.
Octal to decimal conversion
Convert octal 752 to decimal:
7 * 8^2 = 7 * 64 = 448
5 * 8^1 = 5 * 8 = 40
2 * 8^0 = 2 * 1 = 2
Total = 490
Same positional logic, base 8 instead of 10.
Why isn’t octal more popular?
Octal was common in early computing when machines used 12-bit, 24-bit, or 36-bit word sizes that divided evenly by 3. Modern processors use 8-bit bytes, 16-bit, 32-bit, and 64-bit words, all of which divide evenly by 4, not 3. Hex (4 bits per digit) aligns perfectly. Octal doesn’t. Today, octal survives mainly in Unix permissions and a few legacy systems. The shift from octal to hex tracks directly with the shift from word sizes divisible by 3 to word sizes divisible by 4. PDP-8 programmers in the 1960s used octal because their 12-bit words split into four 3-bit groups. When the 8-bit byte became standard in the 1970s, hex took over.
Citation capsule: Octal (base-8) maps each digit to 3 binary bits. Unix file permissions use octal because read, write, and execute form a 3-bit field. The command chmod 755 grants full owner access and read-execute for others (The Open Group, POSIX specification).
How Do All Four Number Systems Compare?
The table below shows values from 0 to 255 (a full byte range) in decimal, binary, octal, and hex. According to RFC 791 (IETF, 1981), the byte (8 bits, values 0-255) is the fundamental addressable unit in Internet Protocol headers and most modern computing. This reference table covers the complete range.
| Decimal | Binary | Octal | Hexadecimal |
|---|---|---|---|
| 0 | 00000000 | 000 | 00 |
| 1 | 00000001 | 001 | 01 |
| 2 | 00000010 | 002 | 02 |
| 7 | 00000111 | 007 | 07 |
| 8 | 00001000 | 010 | 08 |
| 10 | 00001010 | 012 | 0A |
| 15 | 00001111 | 017 | 0F |
| 16 | 00010000 | 020 | 10 |
| 32 | 00100000 | 040 | 20 |
| 42 | 00101010 | 052 | 2A |
| 64 | 01000000 | 100 | 40 |
| 100 | 01100100 | 144 | 64 |
| 127 | 01111111 | 177 | 7F |
| 128 | 10000000 | 200 | 80 |
| 170 | 10101010 | 252 | AA |
| 200 | 11001000 | 310 | C8 |
| 240 | 11110000 | 360 | F0 |
| 255 | 11111111 | 377 | FF |
A few patterns worth noticing. Powers of 2 always have exactly one 1-bit in binary. Round numbers in hex (10, 20, 40, 80) correspond to powers of 16. And octal gets messy with 8-bit values because 8 doesn’t divide evenly into 3-bit groups.
Is there a trick to memorizing these? Not really. But after a few weeks of working with hex and binary, common values like 0xFF (255), 0x80 (128), and 0x7F (127) become second nature.
Where Are These Number Systems Used in the Real World?
Every number system has specific practical applications in modern technology. According to Stack Overflow’s 2024 Developer Survey, 72% of professional developers work with web technologies where hex notation appears in color codes, hash values, and memory addresses daily. Here’s where each system shows up.
Hex: colors, hashes, and memory
Hex dominates whenever you need to represent binary data in human-readable form:
- CSS colors:
#FF5733means red=255, green=87, blue=51 - SHA-256 hashes:
e3b0c44298fc1c14...(64 hex characters = 256 bits) - MAC addresses:
00:1A:2B:3C:4D:5E(6 bytes in hex) - Memory addresses:
0x7FFEEFBFF4A0(pointer values in debuggers) - Unicode code points:
U+1F600(the grinning face emoji)
Binary: networking and bitwise operations
Binary appears directly in:
- Subnet masks:
255.255.255.0is11111111.11111111.11111111.00000000 - Bitwise flags: Feature toggles stored as single bits (e.g.,
0b1010= features 2 and 4 enabled) - File headers: Magic bytes that identify file types (PNG starts with
10001001)
Octal: permissions and legacy systems
Octal is rare today, but critical in a few places:
- Unix permissions:
chmod 644(owner read-write, others read-only) - C/C++ literals: A leading zero means octal (
010= 8 in decimal, a classic bug) - Some embedded systems with non-standard word sizes
Decimal: everything human-facing
Any number a user sees should be decimal. IP addresses (192.168.1.1), port numbers (443), file sizes (2.4 MB), dates, prices, scores. Decimal is the interface between computers and people. We’ve found that the most common conversion mistake developers make is forgetting that a leading zero in JavaScript and C means octal. Writing parseInt("010") in older JavaScript returns 8, not 10. Modern strict mode fixed this, but legacy codebases still have bugs from it.
The leading zero trap
In C, C++, and older JavaScript, an integer literal with a leading zero is interpreted as octal. The value 0100 is 64, not 100. This causes subtle bugs that are hard to trace. Always use 0x prefix for hex and 0b for binary to be explicit.
Citation capsule: Hex is used for CSS colors, hash digests, MAC addresses, and memory pointers. Octal handles Unix permissions. Binary appears in subnet masks and bitwise operations. According to Stack Overflow’s 2024 survey, 72% of developers work with web technologies that use hex notation daily (Stack Overflow).
Quick Conversion Cheat Sheet
Need a fast reference for converting between bases? Here are the most common methods, summarized.
Any base to decimal
Multiply each digit by its positional value (base raised to the position power), then sum:
Hex B4 → (11 * 16) + (4 * 1) = 176 + 4 = 180
Oct 27 → (2 * 8) + (7 * 1) = 16 + 7 = 23
Bin 1011 → 8 + 0 + 2 + 1 = 11
Decimal to any base
Divide repeatedly by the target base, collect remainders in reverse:
Decimal 180 to hex:
180 / 16 = 11 remainder 4
11 / 16 = 0 remainder 11 (B)
Read bottom to top: B4
Binary to/from hex (the shortcut)
Group binary digits into sets of 4 (from the right) and convert each group:
Binary: 1011 0100
Hex: B 4
Binary to/from octal (the shortcut)
Group binary digits into sets of 3 (from the right) and convert each group:
Binary: 010 110 100
Octal: 2 6 4
These grouping shortcuts work because 16 = 2^4 and 8 = 2^3. Each hex digit is exactly 4 bits. Each octal digit is exactly 3 bits. No arithmetic required, just pattern matching. Most conversion tables skip the grouping shortcut and force you through decimal as an intermediate step. That’s unnecessary for hex-to-binary or octal-to-binary. Going directly between these bases is faster and less error-prone because you’re doing a simple lookup, not a multi-step calculation.
practice conversions with the tool
Frequently Asked Questions
Why do computers use binary instead of decimal?
Computer processors use transistors that have two reliable states: on (1) and off (0). Building circuits with exactly two voltage levels is far simpler and more reliable than distinguishing ten levels. Claude Shannon’s 1937 thesis at MIT proved that two-state Boolean logic could implement any computation. According to Intel, modern x86-64 processors perform all arithmetic in binary registers up to 64 bits wide.
How do you convert hex to decimal by hand?
Multiply each hex digit by its positional power of 16, then add the results. For #2F: 2 x 16 = 32, plus F (15) x 1 = 15, equals 47. Remember that A=10, B=11, C=12, D=13, E=14, F=15. For large hex values, work left to right, accumulating the running total.
What does 0xFF mean in programming?
0xFF is hexadecimal notation for the decimal value 255, which is 11111111 in binary. It represents the maximum value of a single unsigned byte. The 0x prefix tells the compiler or interpreter to read the number as hex. You’ll see it constantly in color codes, bitmasks, and byte-level operations.
Why are Unix permissions in octal?
Each permission (read, write, execute) is one bit. Three permissions per user class (owner, group, others) make a 3-bit group. Octal digits map perfectly to 3-bit groups, so the permission rwxr-xr-x compresses to 755. The Open Group’s POSIX specification standardizes this notation for the chmod command.
Can you convert between hex and binary without going through decimal?
Yes, and it’s the fastest method. Each hex digit maps directly to 4 binary bits. To convert A3 to binary, replace A with 1010 and 3 with 0011, giving 10100011. The reverse works the same way: group binary digits into sets of 4 from the right, then look up each group. No multiplication or division needed.
Wrapping Up
Number systems are simpler than they look. Decimal uses powers of 10. Binary uses powers of 2. Hex uses powers of 16. Octal uses powers of 8. The conversion logic is identical across all four: multiply digits by positional values, sum the results. Going the other direction, divide and collect remainders.
In practice, you’ll use decimal for human-facing values, binary for understanding low-level operations, hex for reading colors and hashes, and octal almost exclusively for Unix permissions. The hex-to-binary shortcut (4 bits per digit) is worth memorizing because it eliminates the need for decimal as a middleman.
If you’re tired of doing conversions by hand, the number base converter at the top of this page handles it instantly. Type a value in any base and see all four representations side by side.