Number Base Converter

MATH FREE

Free number base converter. Convert between binary, octal, decimal, and hexadecimal instantly. Perfect for programming and networking.

Convert between binary, octal, decimal, and hex

A number base converter takes a value in one base and shows it in all four common bases used in computing: binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). Enter 255 as decimal and it returns 11111111 in binary, 377 in octal, and FF in hex, all side by side.

How the conversion works

Every base works the same way: each digit is multiplied by the base raised to its position, counting from the right starting at zero, and the results are added. Decimal 255 is two hundreds, five tens, and five ones. Hexadecimal FF is fifteen sixteens plus fifteen ones, which is 240 + 15 = 255.

The tool accepts digits valid for the selected base only: binary allows 0 and 1, octal allows 0 through 7, decimal allows 0 through 9, and hex allows 0 through 9 and A through F. Anything outside that set is rejected with a message. Only non-negative whole numbers are handled; signs, decimal points, and prefixes are not parsed.

Worked example using the default value

The form loads 255 with the input base set to decimal. To see where the hex result comes from, divide by 16 repeatedly and keep the remainders:

DivisionQuotientRemainderHex digit
255 ÷ 161515F
15 ÷ 16015F

Reading the remainders bottom to top gives FF. The binary form is 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255, written 11111111. The octal form uses powers of eight: 3 × 64 + 7 × 8 + 7 × 1 = 192 + 56 + 7 = 255, written 377.

Reference: the same values in four bases

DecimalBinaryOctalHex
0000
81000108
10101012A
15111117F
16100002010
64100000010040
100110010014464
20011001000310C8
25511111111377FF

One byte holds exactly eight bits, which is two hex digits, so any value from 0 to 255 fits in two hex characters. That alignment is why hex is the standard shorthand for binary in programming.

Common mistakes

  • Reading hex letters as decimal. A is 10, B is 11, through F which is 15. They are digits, not labels.
  • Forgetting the input base. The string 10 is two in binary, eight in octal, ten in decimal, and sixteen in hex. Select the base deliberately.
  • Leaving a prefix on the input. The tool does not strip 0x or 0b, so enter the digits alone and choose the base from the dropdown.
  • Trying decimals or negatives. Fractional and signed values are outside the scope of this converter and are rejected.

Why do programmers use hexadecimal?

Because four binary bits map to exactly one hex digit, so a byte is two hex characters with no wasted space. Hex is far shorter than binary and far easier to read than a long run of ones and zeros, which makes it ideal for memory addresses, colour codes, and byte values.

How do I read a binary number by hand?

Write the place values as powers of two from the right: 1, 2, 4, 8, 16, 32, 64, 128. Add the place values under each 1. For 1100100 that is 64 + 32 + 4 = 100, so the decimal value is 100.

Where is octal still used?

Chiefly in Unix file permissions, where each permission triplet is one octal digit, and in some low-level system settings. It survives mainly for historical reasons, since hex covers the same ground with finer bit alignment.

What is the largest value this converter handles?

Any non-negative whole number that stays within the safe integer range, which comfortably covers ordinary programming values. Extremely large inputs lose precision once they exceed the range JavaScript can represent exactly.

Hex and RGB are the same numbers in two notations, so the hex to RGB converter is the direct follow-on for colour work, and the unit converter handles byte, kilobyte, and gigabyte values that are also built on powers of two.