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.

Examples:

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.

Bit width
Actions
From the converter
Binary0000 0000
Hexadecimal00
Decimal (unsigned)0
Decimal (two’s complement)0

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)

DecimalBinaryOctalHex
0000000
1000111
2001022
3001133
4010044
5010155
6011066
7011177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F
160001 00002010

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

PowerDecimalHexWhere you see it
2011One step up from all bits zero
2122
2244
2388
241610Exactly one hex digit
253220
266440
2712880
28256100Values one byte can hold
29512200
2101,024400One kibibyte (1 KiB)
21665,53610000Values two bytes can hold
2201,048,576100000One mebibyte (1 MiB)
22416,777,2161000000Colours in 24-bit true colour
2324,294,967,296100000000Total 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 widthUnsignedTwo’s complement (signed)Max in hex
4-bit0 to 15-8 to 7F
8-bit0 to 255-128 to 127FF
16-bit0 to 65,535-32,768 to 32,767FFFF
32-bit0 to 4,294,967,295-2,147,483,648 to 2,147,483,647FFFFFFFF

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

DecimalHexBinaryWhat it is
15F1111Largest 4-bit value
16100001 0000First value needing two hex digits
255FF1111 1111Largest value in one byte
2561000001 0000 0000Values one byte can hold
1,0244000100 0000 00002 to the power of 10, one KiB
4,095FFF1111 1111 1111Largest value in three hex digits
65,535FFFF1111 1111 1111 1111Largest value in two bytes

Base Conversion Quiz

Random conversion problems across binary, decimal and hexadecimal. See how long a streak you can build.

Difficulty

  1. Type the number you want to convert into any one of the fields, for example 42 into the decimal box.
  2. Every other base updates as you type.
  3. The “Custom base” field takes any base from 2 to 36. Pick the base from the dropdown next to it.
  4. “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.
  5. In “Bit View and Two’s Complement”, click the cells to set and clear bits and watch the unsigned and signed readings diverge.
  6. 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.

Please also review the Terms of Use for this web app before using it.

Found a bug or have feedback? Let us know here.

Report bugs, display issues, usability problems, or suggestions for improvement.
Consent
・This form is for bug reports only. In principle, we do not respond to individual submissions.
・If a submission contains defamatory, threatening, or otherwise inappropriate content, we may take appropriate action based on logs such as IP addresses.

目次