Number Base Conversion: Binary, Octal, Decimal, and Hex Explained

Every number base uses the same underlying idea β€” positional value β€” just with a different number of digits to work with.

Positional value is the same idea in every base

Each digit's contribution equals the digit multiplied by the base raised to its position, counting from zero at the rightmost digit. This single rule is what makes 10 decimal, 1010 binary, and A hexadecimal all describe the same quantity in different bases.

Binary: the native language of hardware

Binary uses only 0 and 1 because transistors naturally represent two stable states (on/off). Every other representation computers show you β€” decimal numbers, hex colors, text β€” is ultimately stored as binary underneath.

Hexadecimal: compact shorthand for binary

Hex uses 0-9 then A-F for values 10-15. Because 16 is a power of 2, each single hex digit maps exactly to 4 binary bits, making hex a much shorter, human-readable stand-in for long binary strings β€” which is why it shows up in color codes and memory addresses.

Octal: a smaller but similar shorthand

Octal uses digits 0-7, and each octal digit maps to exactly 3 binary bits. It was common in early computing and still appears in specific contexts like Unix file permission notation (e.g. 755).

Fast conversion without long division

To convert binary to hex or octal (or back), group the binary digits into sets of 4 (for hex) or 3 (for octal) from the right and convert each group independently β€” no need to go through decimal at all.

Bases beyond 16: up to base 36

Any base from 2 to 36 can be represented using digits 0-9 followed by letters A-Z for values 10-35. Base 36 is a practical ceiling using the standard alphanumeric character set, and shows up in compact ID and URL-shortening schemes.

Why binary underlies every computing unit

A transistor is fundamentally a two-state switch, so binary is not a design choice but a direct reflection of the hardware. A byte (8 bits) became the standard grouping size early in computing history, and hexadecimal became popular specifically because two hex digits represent one byte exactly, with no rounding or awkward remainder.

Fast conversion tricks without a calculator

Converting to decimal is just summing each digit times its place value (base^position). Converting binary to hex or octal is faster by grouping bits directly rather than round-tripping through decimal. For quick sanity checks, memorizing powers of 2 up to 2^16 makes binary and hex arithmetic far faster to eyeball.

Frequently Asked Questions

Why do programmers prefer hex over binary for reading memory addresses?

A single byte needs 8 binary digits but only 2 hex digits to represent, since 16 is a power of 2 and maps cleanly onto 4-bit groups. That makes hex dramatically more compact and easier to read at a glance while still mapping exactly onto the underlying binary.

What's the largest base people commonly use?

Base 36 is the practical ceiling when using the standard 0-9 and A-Z character set, since there are no more single characters left to represent higher digit values. It shows up in compact identifier and URL-shortening schemes where a short string needs to represent a large number.