Binary, Octal, Decimal, Hex: Number Bases Explained
Every number you see in a computer's internals — memory addresses, colour values, file permissions — is expressed in a different base than the decimal system you grew up with. Understanding binary, octal, decimal, and hexadecimal unlocks a crucial layer of how computers work. This guide takes you from zero to confident conversion in one read.
What Is a Number Base?
A number base (or radix) defines how many unique digits a counting system uses. In base 10 (decimal) — the system you use every day — there are 10 digits: 0–9. When you exceed 9, you carry into the next column. In base 2 (binary), there are only 2 digits: 0 and 1. In base 16 (hexadecimal), there are 16 digits: 0–9 plus A–F.
| Base | Name | Digits Used | Prefix |
|---|---|---|---|
| 2 | Binary | 0, 1 | 0b |
| 8 | Octal | 0–7 | 0o |
| 10 | Decimal | 0–9 | (none) |
| 16 | Hexadecimal | 0–9, A–F | 0x |
Why Computers Use Binary
Transistors, the building blocks of modern processors, have two stable states: on (voltage present = 1) and off (no voltage = 0). A system built around two states is vastly simpler and more reliable than one built around ten. Boolean logic (AND, OR, NOT) maps perfectly onto binary, making arithmetic and data storage straightforward to implement in hardware.
Converting Between Bases
Binary to Decimal: Multiply each bit by 2 to the power of its position (from right, starting at 0), then sum. 1011₂ = 1×8 + 0×4 + 1×2 + 1×1 = 11₁₀
Decimal to Binary: Repeatedly divide by 2, writing down remainders. 11 ÷ 2 = 5r1, 5 ÷ 2 = 2r1, 2 ÷ 2 = 1r0, 1 ÷ 2 = 0r1 → read remainders bottom to top: 1011₂
Hex to Decimal: Same as binary but with base 16. FF₁₆ = 15×16 + 15×1 = 240 + 15 = 255₁₀
Binary to Hex shortcut: Group binary digits in fours from the right, convert each group to a hex digit. 1111 0011₂ = F3₁₆
Hexadecimal in Practice
Hex is everywhere in computing because one hex digit represents exactly 4 binary digits (a nibble), making it a compact way to write binary data:
- HTML/CSS colours:
#FF5733is R=FF (255), G=57 (87), B=33 (51) - Memory addresses:
0x00007FFD8B4A2C10 - File checksums:
SHA-256: a3f5c... - Character encoding: Unicode code point U+1F600 (😀) is expressed in hex
- Debugging: hex dumps show raw bytes as two hex digits each
Octal and Unix Permissions
Octal's main surviving use is Unix file permissions. Each permission group (owner, group, others) has three bits: read (4), write (2), execute (1). These three bits can be expressed as a single octal digit 0–7. The common permission chmod 755 means owner=7 (4+2+1 = rwx), group=5 (4+0+1 = r-x), others=5 (r-x).
Convert Between Bases Online
Use the ToolsBox Number Base Converter to instantly convert any number between binary, octal, decimal, and hexadecimal. Enter a value in any base and see all four representations at once. No signup required.
Convert between binary, octal, decimal and hex — free
Enter a number in any base and see all four representations instantly. No signup needed.Frequently Asked Questions
Why do computers use binary?
Transistors have two stable electrical states (on/off = 1/0). A system built on two states is simpler and more reliable than one requiring ten distinct voltage levels. Binary maps naturally to Boolean logic, making arithmetic circuits straightforward to design.
What is hexadecimal used for?
Hex represents binary data compactly — one hex digit = four binary digits = one nibble. It is used for HTML/CSS colours (#FF5733), memory addresses (0x00FF), file checksums, Unicode code points, and debugging raw byte data.
How do I convert binary to decimal?
Multiply each binary digit by 2 raised to its position (right=0), then sum. 1011₂ = 1×8 + 0×4 + 1×2 + 1×1 = 11₁₀. Or use the ToolsBox Number Base Converter for instant conversion.
What is base 8 (octal) used for?
Octal's primary modern use is Unix/Linux file permissions. Each permission group (owner/group/others) has three bits (read=4, write=2, execute=1) that combine into a single octal digit 0–7. chmod 755 = rwxr-xr-x.
← Back to Blog | Related tool: Number Base Converter