Number Base Converter

Binary, octal, decimal and hex.

Free. Runs in your browser: nothing you enter or open is uploaded.

    Two's complement

    How the number is stored in a fixed number of bits. Negative numbers use two's complement; a bit pattern can also be read back as signed or unsigned.

    BitsBinaryHexAs signedAs unsigned

    Numbers of any size are handled exactly with BigInt, so a 128 bit value converts without rounding. Prefixes 0x, 0b and 0o are understood, and spaces and underscores between digits are ignored. Whole numbers only.

    How to use it

    1. Type a number and choose the base it is written in, or paste one with a 0x, 0b or 0o prefix.
    2. Read it in binary, octal, decimal, hex and any base from 2 to 36.
    3. Check the two's complement table to see how it is stored in 8, 16, 32 or 64 bits.

    Questions

    How do I convert binary to decimal by hand?

    Each digit is worth twice the one to its right: 1, 2, 4, 8 and so on. Add up the values of the digits that are 1. For 1011 that is 8 + 2 + 1 = 11.

    What is two's complement?

    The way computers store negative whole numbers. To negate a number, flip every bit and add one. In 8 bits, -1 is 11111111 and -128 is 10000000, which is why a signed byte runs from -128 to 127.

    Why do hex numbers use letters?

    Base 16 needs sixteen digits, so after 0 to 9 it uses A to F for 10 to 15. One hex digit is exactly four bits, which makes hex a compact way to write binary.

    What is the largest number it can convert?

    There is no fixed limit: BigInt grows as needed. Very long numbers of many thousands of digits just take a little longer.