Number Base Converter Guide: Binary, Decimal, Hex, and Octal
Quick answer
Master number system conversions. Learn binary, hexadecimal, octal, and decimal with step-by-step conversion methods. This guide answers that in plain language, with the practical steps first and the background afterwards.
Key facts
| What this article covers | Master number system conversions. Learn binary, hexadecimal, octal, and decimal with step-by-step conversion methods. |
|---|---|
| Topic | Tech |
| Reading time | 10 min read |
| Published | April 3, 2026 |
| Written by | The SimpleCounter editorial team, who build and use these counting tools. |
| Cost of the tools mentioned | Free, with no account required. |
Colour codes in CSS, file permissions on a Linux server, memory addresses in a debugger, and IP subnet masks all use bases other than ten. Once you can move between binary, octal, decimal, and hexadecimal by hand, those notations stop being opaque strings and start being numbers you can reason about.
What a Base Actually Means
The base tells you how many digits are available and what each position is worth. In base ten, the digits are 0 to 9 and positions are powers of ten, so 407 is 4 hundreds, 0 tens, 7 units. In base two the digits are 0 and 1 and positions are powers of two. In base sixteen there are sixteen digits, so letters fill in past 9: A is 10, B is 11, C is 12, D is 13, E is 14, F is 15.
Binary to Decimal
Write the place values above the digits and add the ones that are set. For 10110110, the places from the right are 1, 2, 4, 8, 16, 32, 64, 128. The set bits are at 2, 4, 16, 32, and 128, giving 128 + 32 + 16 + 4 + 2 = 182. An 8-bit byte covers 0 to 255, which is why colour channels and older character codes stop at 255.
Decimal to Binary
Divide repeatedly by two and read the remainders bottom to top. For 156: 156/2 = 78 r0, 78/2 = 39 r0, 39/2 = 19 r1, 19/2 = 9 r1, 9/2 = 4 r1, 4/2 = 2 r0, 2/2 = 1 r0, 1/2 = 0 r1. Reading upward gives 10011100. A quicker route for people who know the powers of two is greedy subtraction: 156 minus 128 is 28, minus 16 is 12, minus 8 is 4, minus 4 is 0, so bits 128, 16, 8, and 4 are set, which is the same 10011100.
Hexadecimal Is Just Binary in Groups of Four
Because sixteen is two to the fourth power, every hex digit maps to exactly four bits. That makes conversion mechanical rather than arithmetic.
- 0 = 0000, 1 = 0001, 2 = 0010, 3 = 0011
- 4 = 0100, 5 = 0101, 6 = 0110, 7 = 0111
- 8 = 1000, 9 = 1001, A = 1010, B = 1011
- C = 1100, D = 1101, E = 1110, F = 1111
So B6 in hex is 1011 0110 in binary, which is the 182 we calculated earlier. Going the other way, group the bits in fours from the right and translate each group. This is why programmers write memory addresses in hex: one glance gives you the bit pattern.
Octal and Unix File Permissions
Octal uses digits 0 to 7 and each digit maps to three bits. Its main surviving use is file permissions, where read is 4, write is 2, and execute is 1. A permission of 755 means the owner has 4+2+1 (read, write, execute), while group and others have 4+1 (read and execute). 644 means the owner can read and write while everyone else can only read. Understanding that each digit is a three-bit field makes chmod values obvious instead of memorised.
Converting Between Any Two Bases
The general approach is to route through decimal: convert the source number to decimal by multiplying each digit by its place value, then convert decimal to the target base by repeated division. Base 12 number 2A5 becomes 2 x 144 + 10 x 12 + 5 = 413 in decimal, and 413 into base 7 is 1136, since 413 = 1 x 343 + 1 x 49 + 3 x 7 + 6. When both bases are powers of two, skip decimal entirely and regroup the bits.
Where These Bases Turn Up Day to Day
| Context | Base | Example |
|---|---|---|
| CSS colour | 16 | #1E90FF is R=30, G=144, B=255 |
| Subnet mask | 2 | /24 is 11111111.11111111.11111111.00000000 |
| File permissions | 8 | chmod 755 |
| Unicode code point | 16 | U+00E9 is the letter e with an acute accent |
Mistakes That Cause Bugs
Reading a hex value as decimal is the classic one: port 0x50 is 80, not 50. Forgetting that a leading 0 in some languages means octal turns 010 into 8. Assuming a fixed width also bites, since 0xFF is one byte but 0x0FF written into a 16-bit field leaves the top byte zero. Prefixes exist to prevent all three, so keep 0b for binary, 0o for octal, and 0x for hex in code and notes.
Convert Bases With a Free Tool
The number base converter on SimpleCounter moves values between binary, octal, decimal, and hexadecimal in one field, showing the equivalent in every base at once. It is useful for checking a colour code, a permission value, or a bit pattern, and it runs entirely in your browser.
How this page relates to the rest of the site
- Type of
- Guide
- Related tools
- Calculators and converters
- Published by
- SimpleCounter
Related articles
Data Storage Guide: Bytes, KB, MB, GB, TB
Understand digital storage units and conversions.
Hexadecimal Guide: Hex Numbers and Colors
Master hexadecimal for colors and computing.
Binary Calculator Guide: Binary Arithmetic
Learn binary number system and computer math.
Get Counting Tips in Your Inbox
Subscribe for productivity tips, counting techniques, and new feature updates.
No spam, unsubscribe anytime.