Number Base Converter
This tool has been used … times.
Convert between decimal, binary, octal, hexadecimal and any base from 2 to 36 in real time. Beyond the answer, it shows the working out for both repeated division and positional weights, a two’s complement simulator whose bits you can click, and a base conversion quiz to test yourself. Built for anyone learning how computers store numbers.
Convert Binary, Octal, Decimal and Hexadecimal
Type into any field and the others update instantly. Integers only.
How the Conversion Works, Step by Step
The working out for whatever value is in the converter above. Choose which base to show.
Decimal to base 2 (repeated division)
Base 2 to decimal (positional weights)
Bit View and Two’s Complement Simulator
Click a cell to flip that bit. The same bit pattern reads as one number unsigned and a different one in two’s complement, and you can watch it happen.
The leftmost bit (the most significant bit, or MSB) carries a negative weight in two’s complement. Set every bit to 1 and see for yourself: unsigned gives the maximum value, two’s complement gives −1.
Reference Charts
The values worth knowing by heart. Type any of them into the converter above to see the working out.
Binary, octal, decimal and hexadecimal (0 to 16)
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 3 | 0011 | 3 | 3 |
| 4 | 0100 | 4 | 4 |
| 5 | 0101 | 5 | 5 |
| 6 | 0110 | 6 | 6 |
| 7 | 0111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 11 | 1011 | 13 | B |
| 12 | 1100 | 14 | C |
| 13 | 1101 | 15 | D |
| 14 | 1110 | 16 | E |
| 15 | 1111 | 17 | F |
| 16 | 0001 0000 | 20 | 10 |
Decimal 10 through 15 become the single characters A through F in hexadecimal. Only at 16 does hex finally need a second digit.
Powers of two
| Power | Decimal | Hex | Where you see it |
|---|---|---|---|
| 20 | 1 | 1 | One step up from all bits zero |
| 21 | 2 | 2 | — |
| 22 | 4 | 4 | — |
| 23 | 8 | 8 | — |
| 24 | 16 | 10 | Exactly one hex digit |
| 25 | 32 | 20 | — |
| 26 | 64 | 40 | — |
| 27 | 128 | 80 | — |
| 28 | 256 | 100 | Values one byte can hold |
| 29 | 512 | 200 | — |
| 210 | 1,024 | 400 | One kibibyte (1 KiB) |
| 216 | 65,536 | 10000 | Values two bytes can hold |
| 220 | 1,048,576 | 100000 | One mebibyte (1 MiB) |
| 224 | 16,777,216 | 1000000 | Colours in 24-bit true colour |
| 232 | 4,294,967,296 | 100000000 | Total IPv4 addresses |
Every extra binary digit doubles how many values you can represent. Hexadecimal gains a digit every 4 bits, which is why the two line up so neatly.
Range by bit width
| Bit width | Unsigned | Two’s complement (signed) | Max in hex |
|---|---|---|---|
| 4-bit | 0 to 15 | -8 to 7 | F |
| 8-bit | 0 to 255 | -128 to 127 | FF |
| 16-bit | 0 to 65,535 | -32,768 to 32,767 | FFFF |
| 32-bit | 0 to 4,294,967,295 | -2,147,483,648 to 2,147,483,647 | FFFFFFFF |
One bit pattern, two meanings, depending on whether you read it as unsigned or as two’s complement. The simulator above lets you check it directly.
Round numbers worth recognising
| Decimal | Hex | Binary | What it is |
|---|---|---|---|
| 15 | F | 1111 | Largest 4-bit value |
| 16 | 10 | 0001 0000 | First value needing two hex digits |
| 255 | FF | 1111 1111 | Largest value in one byte |
| 256 | 100 | 0001 0000 0000 | Values one byte can hold |
| 1,024 | 400 | 0100 0000 0000 | 2 to the power of 10, one KiB |
| 4,095 | FFF | 1111 1111 1111 | Largest value in three hex digits |
| 65,535 | FFFF | 1111 1111 1111 1111 | Largest value in two bytes |
Base Conversion Quiz
Random conversion problems across binary, decimal and hexadecimal. See how long a streak you can build.
- Type the number you want to convert into any one of the fields, for example 42 into the decimal box.
- Every other base updates as you type.
- The “Custom base” field takes any base from 2 to 36. Pick the base from the dropdown next to it.
- “How the Conversion Works” shows the repeated division and the positional weight expansion side by side. Use the buttons to switch which base is displayed.
- In “Bit View and Two’s Complement”, click the cells to set and clear bits and watch the unsigned and signed readings diverge.
- Pick a difficulty and press Start on the quiz. Type your answer and press “Check answer”, or just hit Enter.
Scope and limitations
- Integers only. Fractional values such as 0.101 are not supported.
- Negative numbers work (-42 becomes -101010). They are shown with a sign, which is a different notation from the two’s complement bit pattern in the simulator.
- The largest supported magnitude is 9,007,199,254,740,991 (2 to the power of 53, minus 1). Anything beyond that loses precision, so it is rejected as an error.
- Hexadecimal letters A to F can be typed in either upper or lower case.
- Your quiz best score is stored in this browser only, using localStorage.
Frequently Asked Questions
- How do binary and hexadecimal line up?
- Four binary digits make exactly one hexadecimal digit, because 2 to the power of 4 is 16. Take the binary number 1010 1111, split it into groups of four, and swap each group for its hex digit to get AF. That direct mapping is why programmers reach for hexadecimal whenever raw binary gets too long to read.
- What is two’s complement, and why is it used?
- It is how computers represent negative integers. The most significant bit is given a negative weight, which means the same addition circuitry can handle subtraction too, with no special case for the sign. In 8 bits, 1111 1111 reads as 255 unsigned but as −1 in two’s complement. The bit view above shows both readings of the same pattern at once.
- How do hex colour codes like #FF5733 relate to this?
- A web colour code is the strength of red, green and blue, each from 0 to 255, written as two hexadecimal digits apiece. In #FF5733 that is red FF (255), green 57 (87) and blue 33 (51). Convert FF in the tool above and you will get 255.
- Can it convert fractions or decimal points?
- No, this tool handles integers only. Converting a fractional value (decimal 0.625 to binary 0.101, say) means repeatedly multiplying the fraction by the base and taking the integer part each time. It often fails to terminate in a finite number of digits, so it works differently enough to be left out.
Related Tools
Other tools that deal in bases, bits and colour codes.