ToolboxHub

Number Bases Explained: Binary, Octal, Decimal, and Hexadecimal

7 min read

Numbers feel absolute, but the way we write them is just a convention. The quantity we call thirteen can be written as 13, as 1101, as 15, or as D, and all four are correct; they are simply the same value expressed in different number bases. Understanding bases is one of those small pieces of knowledge that quietly unlocks a lot of computing, from reading a hex color code to making sense of file permissions or a memory address in a debugger. This guide builds the idea up from the decimal you already know.

What Is a Number Base?

A number base, also called a radix, is the number of distinct digits a system uses to represent values. Once you run out of single digits, you start combining them, and the position of each digit carries a weight that is a power of the base.

The base you grew up with is base 10, which has ten digits, zero through nine. Computers, however, are built from switches that are either on or off, so they naturally work in base 2. Two other bases, base 8 and base 16, exist mainly because they are compact, convenient shorthands for the long strings of bits that base 2 produces. All four describe identical quantities; only the notation changes.

Decimal (Base 10): The Familiar Baseline

Decimal uses ten digits and assigns each position a power of ten, increasing from right to left. The number 472 means four hundreds, seven tens, and two ones, because the rightmost position is ten to the zero, the next is ten to the one, and the next is ten to the two.

You do this place-value arithmetic so automatically that it feels invisible, but the same machinery underlies every other base. The only thing that changes from one base to another is the number you raise to those increasing powers. Keep the place-value idea in mind, because it is the key to every conversion that follows.

Binary (Base 2): The Language of Computers

Binary uses only two digits, zero and one, and each position is a power of two. From right to left the place values are one, two, four, eight, sixteen, thirty-two, and so on, doubling each step. A single binary digit is called a bit, and eight bits make a byte.

Computers use binary because the underlying hardware is built from transistors that are either on or off, charged or uncharged, high voltage or low. Mapping those two physical states to the digits one and zero is the most reliable way to store and move information, since a switch that is clearly on or clearly off is far less error-prone than one that must hold ten distinct voltage levels. Every piece of data in a computer, whether text, image, or instruction, is ultimately a pattern of bits.

Converting Between Decimal and Binary

To turn binary into decimal, write the place value above each bit and add up the values where there is a one. Take 1101: the place values from right to left are one, two, four, and eight. The bits are one, zero, one, one, so you add eight, four, and one while skipping the two, which gives thirteen. That is why 1101 in binary equals 13 in decimal.

Going the other way, from decimal to binary, you can repeatedly divide by two and collect the remainders. Thirteen divided by two is six remainder one, six divided by two is three remainder zero, three divided by two is one remainder one, and one divided by two is zero remainder one. Reading the remainders from last to first spells 1101. An easier mental method is to subtract the largest power of two that fits: thirteen contains eight, leaving five, which contains four, leaving one, which contains one, so the bits for eight, four, and one are set and the bit for two is not, giving 1101 again.

Octal (Base 8): Grouping Three Bits

Octal uses eight digits, zero through seven, and each position is a power of eight. Its usefulness comes from a neat coincidence: eight is two cubed, so every octal digit corresponds to exactly three binary digits. The bits 101 are five, the bits 111 are seven, and so a long binary number can be read off three bits at a time as a much shorter octal number.

Before hexadecimal became dominant, this made octal a popular shorthand for raw bits. It survives today most visibly in Unix file permissions, where a mode like 755 is really three octal digits, each encoding the read, write, and execute bits for the owner, group, and others. A single digit of 7 means all three bits are set, while a 5 means read and execute but not write.

Hexadecimal (Base 16): Compact and Everywhere

Hexadecimal uses sixteen digits. The first ten are the familiar zero through nine, and then the letters A through F stand for ten through fifteen, so A is ten, B is eleven, and F is fifteen. Each position is a power of sixteen.

Hex is popular for the same reason octal once was, only more so: sixteen is two to the fourth, so every hex digit maps to exactly four bits, and a single byte of eight bits fits in precisely two hex digits. That makes hex the natural way to write bytes compactly. You see it in RGB color codes on the web, where a value like FF stands for the maximum intensity 255, in memory addresses shown by debuggers, and in the output of hash functions, which are usually printed as long hexadecimal strings.

Converting Between Hex and Binary

Because one hex digit equals exactly four bits, converting between hex and binary needs no arithmetic, only a lookup. Split the binary number into groups of four bits from the right, then translate each group into its hex digit. The byte 11010010 splits into 1101 and 0010; 1101 is thirteen, which is D, and 0010 is two, so the byte is D2 in hex.

The reverse is just as direct: expand each hex digit into its four-bit pattern and concatenate. The hex value 2F becomes 0010 for the 2 and 1111 for the F, giving 00101111. This clean four-bits-per-digit relationship is exactly why programmers reach for hex when they need to inspect raw memory or byte data, since the hex view lines up neatly with the underlying bits.

Where Each Base Shows Up

Each base has a home turf. Decimal is for everyday human-facing numbers and ordinary arithmetic. Binary is the true internal form of all data and the right lens when you care about individual bits, flags, or bitmasks. Octal lingers chiefly in Unix file permissions, where a chmod value like 644 or 755 is three octal digits describing access bits.

Hexadecimal is the workhorse of low-level computing. RGB and RGBA colors in CSS are written as hex, so a designer specifying a shade of blue might use a six-digit hex code. Memory addresses, pointer values, and stack traces in debuggers are shown in hex because it maps cleanly to bytes. The fingerprints produced by hash functions like MD5 and SHA-256 are displayed as hex strings, which is why a checksum looks like a long run of digits and the letters a through f.

Convert Any Number with ToolboxHub

Doing base conversions by hand is good for understanding, but tedious in practice and easy to get wrong on long values. The free ToolboxHub Base Converter handles it instantly: enter a number in binary, octal, decimal, or hexadecimal and it shows the equivalent in all the other bases at once, entirely in your browser with nothing sent to a server. It is handy for reading a hex color, checking an octal permission, or sanity-checking a binary value while you debug.

It pairs naturally with related tools. The Binary Text Converter turns text into its binary or back, which is useful when you want to see how characters are encoded as bits. The Hash Generator produces MD5 and SHA-256 digests, whose hexadecimal output is a perfect example of base 16 in the wild.

Key Takeaways

A number base, or radix, is simply how many digits a system uses, and each position carries a weight that is a power of that base. Decimal is base 10 and the human default. Binary is base 2, the on-or-off language computers are built on, where each position doubles and 1101 equals thirteen. Octal is base 8, where each digit is three bits, and it survives in Unix file permissions. Hexadecimal is base 16 with digits zero through nine and A through F, where each digit is four bits and a byte is two hex digits, which is why it rules colors, memory addresses, and hash output. Converting between hex and binary is a direct four-bits-per-digit swap, while decimal conversions rely on place values and powers. When you would rather not do the math by hand, the free ToolboxHub Base Converter translates a number across all four bases instantly.

Try these tools now — free, no sign-up required:

Related Articles