How Do You Convert Between Binary, Octal, Decimal, and Hexadecimal?

number base conversion — Chunky Munster

Number base conversion is just rewriting the same value in a different counting system. Binary, octal, decimal, and hexadecimal all describe the same underlying number, so the trick is knowing how place value changes from base to base. If you want to sanity-check your work fast, use this number base converter tool.

What a number base actually changes

A number base tells you how many digits a system uses before it rolls over. Decimal uses 10 digits, binary uses 2, octal uses 8, and hex uses 16. That means decimal has digits 0-9, binary has 0-1, octal has 0-7, and hexadecimal adds A-F for values 10 through 15.

The value stays the same. Only the representation changes. 1010 in binary, 12 in octal, 10 in decimal, and A in hex all point to the same quantity.

This is why developers deal with base conversion constantly. Memory addresses, permissions, bitmasks, color codes, and low-level debugging all show up in different bases depending on the problem. If you can read the pattern, the digits stop looking like random noise.

How positional notation works

Every digit in a positional number system is weighted by a power of the base. Read from right to left, each position is worth more than the one before it. In decimal, the rightmost digit is ones, then tens, then hundreds. In binary, it is ones, twos, fours, eights, and so on.

That is why 347 means 3×100 + 4×10 + 7×1 in decimal. In binary, 1011 means 1×8 + 0×4 + 1×2 + 1×1. Same logic, different base.

The easiest way to think about it is this: the base determines the column weights. Once you know the weights, conversion becomes a bookkeeping exercise instead of a guessing game.

Convert to decimal first when you are doing it by hand

If you are converting manually, the safest route is usually to convert the source number into decimal first, then from decimal into the target base. That works because decimal is the bridge most people understand best. It is slower than a tool, but it is reliable and easy to check.

For example, to convert binary 110101 to decimal, expand the powers of two:

110101₂ = 1×32 + 1×16 + 0×8 + 1×4 + 0×2 + 1×1 = 53₁₀

Once you have 53 in decimal, you can convert it into another base by repeated division or by using place values. This is the same method you use when translating between any non-decimal bases by hand.

If you want a deeper look at the way computers store raw binary values, our guide on how binary numbers actually work is the next stop.

Binary, octal, and hex are tightly related

Binary and hex are not just random neighbors. Hex exists because four binary bits fit neatly into one hex digit. That makes hex much shorter to read and write when you are looking at bit patterns.

Octal has the same kind of relationship with binary, but in groups of three bits. It is less common in modern app work than hex, but you still see it in Unix file permissions and some older tooling. A permission like 755 is octal, not decimal.

A useful shortcut is to group bits from the right in chunks of 4 for hex or 3 for octal. Pad with leading zeros if needed. Then convert each chunk directly to its digit equivalent.

When to convert with repeated division

To convert a decimal number into another base, divide the decimal value by the target base and keep the remainders. Read the remainders from bottom to top. That gives you the digits of the new number.

For binary, divide by 2. For octal, divide by 8. For hex, divide by 16. The method is mechanical, which is exactly what you want when the numbers get bigger than your head wants to hold.

Example: convert decimal 53 to binary.

  1. 53 ÷ 2 = 26 remainder 1
  2. 26 ÷ 2 = 13 remainder 0
  3. 13 ÷ 2 = 6 remainder 1
  4. 6 ÷ 2 = 3 remainder 0
  5. 3 ÷ 2 = 1 remainder 1
  6. 1 ÷ 2 = 0 remainder 1

Read the remainders upward: 110101₂. Same number, now in a different mask.

Real-world places you will actually use this

Developers usually run into base conversion in a few specific places. Hex shows up in CSS colors, byte dumps, memory addresses, and hash fragments. Binary shows up in bit flags, masks, protocol fields, and low-level debugging. Octal tends to appear in permissions and some legacy systems.

Here is a practical example from Unix permissions. The octal number 644 maps to rw-r--r--. The first digit controls owner permissions, the second controls group permissions, and the third controls everyone else.

That kind of mapping is why a base converter is more than a classroom toy. It saves time when you need to switch between the compact representation and the human-readable one without mentally translating every digit.

A Worked Example

Let’s convert 255 from decimal into binary, octal, and hex so you can see the same value in three different costumes. This is a common test case because the result is clean and easy to verify.

Decimal: 255

Binary via repeated division by 2:

255 ÷ 2 = 127 remainder 1
127 ÷ 2 = 63 remainder 1
63 ÷ 2 = 31 remainder 1
31 ÷ 2 = 15 remainder 1
15 ÷ 2 = 7 remainder 1
7 ÷ 2 = 3 remainder 1
3 ÷ 2 = 1 remainder 1
1 ÷ 2 = 0 remainder 1

Binary = 11111111

Octal via repeated division by 8:

255 ÷ 8 = 31 remainder 7
31 ÷ 8 = 3 remainder 7
3 ÷ 8 = 0 remainder 3

Octal = 377

Hex via repeated division by 16:

255 ÷ 16 = 15 remainder 15
15 ÷ 16 = 0 remainder 15

Hex = FF

So the same value becomes 11111111₂, 377₈, 255₁₀, and FF₁₆. If that feels suspiciously neat, good. Clean examples are easier to spot-check, and they are exactly what you want while learning the patterns.

Common mistakes that waste time

The biggest mistake is mixing up the base with the value. 10 does not always mean ten. In binary it means two, in octal it means eight, and in hex it means sixteen.

Another common slip is reading hex letters as text instead of digits. A through F are not symbols with mysterious meaning. They are just placeholders for 10 through 15.

People also forget leading zeros when grouping bits. If you need to convert 101 to hex, pad it to 0101 first so the grouping stays aligned. Without padding, you can easily land on the wrong digit.

When the numbers are ugly, use a tool and move on. Manual conversion is useful for understanding, but it is a bad place to spend your afternoon if the real job is debugging something else.

Frequently Asked Questions

How do you convert binary to decimal?

Write each bit with its power-of-two position, then add the values where the bit is 1. For example, 1011₂ becomes 8 + 0 + 2 + 1 = 11. This is the same positional logic used in every base.

How do you convert decimal to hexadecimal?

Divide the decimal number by 16, keep the remainders, and read them from bottom to top. Remainders from 10 to 15 become A through F. For example, 255₁₀ becomes FF₁₆.

Why is hexadecimal used so often in programming?

Hex is compact, easy to map from binary, and readable enough for humans. One hex digit represents four bits, so it is a clean shorthand for byte-level values. That makes it useful for colors, memory, flags, and raw data.

Is octal still used today?

Yes, but less often than binary or hex. The most common place developers still encounter octal is Unix file permissions, like 644 or 755. It is also useful anywhere three-bit grouping matters.

Wrapping Up

Number base conversion is less about memorising tricks and more about understanding place value. Once you know how powers of the base work, binary, octal, decimal, and hex all become different views of the same number.

For manual work, convert through decimal or group bits into chunks of 3 or 4 depending on the target base. For everything else, check your result with the number base converter and keep your brain free for the part that matters.

If you are also dealing with low-level representations, it is worth pairing this with hex, binary, and permission-related problems. Same data, different disguise. That is most of the game.

// try the tool
use this number base converter tool →
// related reading
← all posts