HexaConvert

Number Base Converter

Convert between binary, octal, decimal and hexadecimal, and see the arithmetic that got there. Every digit, division and grouping below is worked out from the number you type.

Binary uses 0 and 1. A minus sign and a point are both allowed, and 0b, 0o or 0x prefixes are understood.

101010 in binary is 42 in decimal.

42 in decimal

101010 in binary = 42 in decimal

  • BIN101010
  • OCT52
  • DEC42
  • HEX2A
How it works
Worked out from the number above, step by step.

Multiply each digit by its place value

The places in base 2 go up in powers of 2, so a digit is worth itself times the power of 2 standing at its position. Add every result together and that total is the decimal number.

The whole part

the digit 0 in the 2 to the power of 0 place, worth 1, contributes 0

the digit 1 in the 2 to the power of 1 place, worth 2, contributes 2

the digit 0 in the 2 to the power of 2 place, worth 4, contributes 0

the digit 1 in the 2 to the power of 3 place, worth 8, contributes 8

the digit 0 in the 2 to the power of 4 place, worth 16, contributes 0

the digit 1 in the 2 to the power of 5 place, worth 32, contributes 32

Add them up42 is the total

Put it back together

The digits, in order, are the answer.

Answer42

About this tool

Converts a whole number or a fraction between binary, octal, decimal and hexadecimal, and shows the arithmetic that produced the answer rather than only the answer. Every place value, division and group of bits on the page is worked out from the number you typed, so the method is visible and can be checked by hand.

How to use it

  1. 1Choose the base you are starting from and the base you want, then type the number.
  2. 2Read the answer at the top; the working underneath shows how it was reached.
  3. 3Use the swap button to run the conversion back the other way, carrying the answer with it.
  4. 4Copy the result, or take any of the four bases from the row beneath it.

Good to know

The method changes with the direction

Because the shortest honest explanation does. Anything into decimal expands each digit by its place value and adds the results. Decimal into anything divides the whole part and multiplies the fraction. Binary and hexadecimal differ by a power of two, so bits are simply grouped in fours with no arithmetic at all, and octal and hexadecimal are converted through binary, which is the only base both of them line up with.

Fractions that never end

A tenth is exact in decimal and endless in binary. Rather than round it and print a value that is not equal to what you typed, the tool watches for a remainder it has seen before. When one comes back, the digits from that point repeat forever, and they are drawn with a line over them. Copied out, the repeating part is written in brackets instead, because an overline does not survive a clipboard.

Exact at any size

Values are held as exact integers rather than floating point, so a two-hundred-digit number converts without drifting in the last places. Past forty-eight rows the middle of the working is summarised, because nobody reads row four hundred, but the answer itself is never abridged.