By · Updated

Hex to Decimal to Binary Converter, Plus Octal

Number Base Converter Online, With Bit Length and the Smallest Integer Type

No ratings yet

OneTask is free, with no sign-up, and built by one person.
If this tool saved you time, a coffee helps keep new ones coming.

How the Base Converter works

This hex to decimal to binary converter also covers octal. Type a number in any of the four common bases and see it in the other three at once, along with its prefixed forms, how many significant bits it uses and the smallest integer type that holds it. Prefixes, spaces and underscores are understood; arbitrary width is supported.

Hex to decimal to binary converter: positional notation

A base is nothing more than how many distinct digits you have before you carry. Decimal has ten, binary two, octal eight, hexadecimal sixteen. The number itself never changes — 255, 0xFF and 11111111 are the same quantity written three ways — and being fluent in the translation is most of what makes low-level code readable.

Hexadecimal exists because it maps cleanly onto bits. One hex digit is exactly four bits, so a byte is always two hex digits and a 32-bit word is always eight. That fixed relationship is why colours, memory addresses, hashes and byte dumps are all written in hex: you can read the bit pattern straight off the page without arithmetic. Decimal has no such alignment, which is why 4278190080 tells you nothing and 0xFF000000 immediately reads as a full alpha channel.

Octal survives mostly in one place. Three bits per digit made it natural on early machines with word sizes divisible by three, and it lost to hexadecimal when eight-bit bytes won. It remains in Unix file permissions, where read, write and execute form a perfect three-bit group and 755 is faster to say than rwxr-xr-x. It also lurks as a hazard: in C and several languages a leading zero means octal, so 010 is eight, which has caused real bugs in date handling.

Prefixes tell the reader and the parser which base you meant. 0b for binary, 0o for octal and 0x for hexadecimal are near-universal in modern languages, and this page reads all three. Without a prefix, a string of digits is genuinely ambiguous, which is why auto-detect here falls back to decimal unless it sees a letter from a to f. When you write a literal in code, use the prefix even where the language would guess correctly.

Bit width is the practical question behind most conversions. A value needing nine bits will not fit in a byte, and a 33-bit value overflows a 32-bit signed integer and wraps to a negative number. The significant-bit count above is the number of bits after leading zeroes, which is what determines whether a value fits a field, a colour channel, a subnet mask or a database column. It is also how you check a bit-shift did what you expected.

Grouping makes long binary readable. Four-bit groups line up with hex digits and eight-bit groups line up with bytes; this page groups by four so you can read each nibble against the hexadecimal row directly underneath. Underscores serve the same purpose in source code and most modern languages accept them in numeric literals.

FAQ

How do I convert hex to decimal by hand?

Multiply each digit by sixteen raised to its position from the right and add the results, treating a–f as ten to fifteen. 0x2F is 2 × 16 + 15 = 47. For longer values it is faster to convert each hex digit to its four bits and read the binary.

Why is hexadecimal used so much in programming?

Because one hex digit is exactly four bits, so the written form maps directly onto the underlying bit pattern with no arithmetic. Bytes are always two digits, words always eight, and colour channels, addresses and hashes all read naturally.

What does the 0x, 0b or 0o prefix mean?

They declare the base of a numeric literal — hexadecimal, binary and octal respectively — so both a compiler and a human reader know how to interpret the digits. Without a prefix, digits are assumed to be decimal in almost every modern language.

Can this handle numbers bigger than 64 bits?

Yes. The conversion uses arbitrary-precision integers, so a 256-bit hash or a very long binary string converts exactly with no rounding or overflow. The width row will tell you when a value has outgrown a 64-bit type.

Why does a leading zero sometimes change a number's value?

In C, Java, JavaScript's older syntax and several other languages, a leading zero marks an octal literal, so 010 is eight rather than ten. Modern code should use the explicit 0o prefix, and several languages now reject the legacy form outright.

See also: all Data & Code tools, Units, Images, Audio & Video, Documents.

Related tools