Binary, Decimal & Hex Converter

Enter a whole number and the base it is written in. You get it in binary, octal, decimal and hexadecimal.

The formula

A number in base b is the sum of each digit times a power of b: 1011 in binary is 1×8 + 0×4 + 1×2 + 1×1 = 11.

Worked example

What are the red, green and blue values of the colour #FF8800?

  1. Split into pairs: FF, 88, 00
  2. FF = 15 × 16 + 15 = 255
  3. 88 = 8 × 16 + 8 = 136
  4. 00 = 0

Red 255, green 136, blue 0.

How it works

  1. To decimal

    Multiply each digit by its place value, a power of the base, and add the results.

  2. From decimal

    Divide by the new base repeatedly and read the remainders from last to first.

  3. Binary and hex

    Each hexadecimal digit is exactly four binary digits, so you can convert in groups of four.

Good to know

Common questions

What do the letters in hexadecimal mean?

A to F stand for the values 10 to 15, since base 16 needs sixteen different digits.

How large a number can I convert?

Any size. The converter uses exact whole-number arithmetic, so long values are not rounded.

Why do computers use binary and people use hexadecimal?

Circuits have two stable states, so binary is natural for hardware. Hexadecimal is a compact way for people to read it: one hex digit replaces four bits.

How many bits does a number need?

The length of its binary form. 255 is 11111111, so it needs 8 bits; 256 needs 9. In general it is the whole-number part of log₂(n), plus 1.

What is the largest value in 8, 16 and 32 bits?

For unsigned values: 255, 65,535 and 4,294,967,295. Each is 2 to the number of bits, minus 1.

More free calculators