Skip to content
MasterMath

Number Base Converter

Convert a number between binary, octal, decimal and hexadecimal, and see all four representations at once.

Result

—

Result—
In decimal—
In binary—
In octal—
In hexadecimal—
Bits needed—

How this was worked out

    The formula

    each digit is worth its value times the base raised to its position

    Where it comes from

    In decimal we use ten symbols and each position is worth ten times the one before. In binary there are only two symbols and each position is worth double; in hexadecimal there are sixteen and each is worth sixteen times more. The number is the same, only the writing changes.

    How to work it out by hand

    1. Number the positions from right to left starting at zero
    2. Multiply each digit by the base raised to its position
    3. Add the results: that is the value in decimal
    4. To go to another base, divide repeatedly and read the remainders backwards

    What is worth knowing

    Hexadecimal is used so widely in computing because each digit is exactly four bits, so a byte always takes two characters. That is why web colours have six digits: two per channel. And it is where the letters A to F come from, standing for the values 10 to 15.

    Frequently asked questions

    How do you convert decimal to binary?

    By dividing by two repeatedly and reading the remainders from the bottom up. 255 in binary is 11111111.

    Why does hexadecimal use letters?

    Because it needs sixteen symbols and there are only ten digits. A is 10, B is 11 and so on to F, which is 15.

    How many bits does a number take?

    As many as its binary representation. 0 to 255 fits in 8 bits, which is exactly one byte.