Math

Hex to Decimal: How to Convert Hexadecimal Numbers

Calcuonline · Updated · 4 min

Three overlapping circles in red, green and blue beside a panel of sixteen tiles, some of them lit

To convert hex to decimal, multiply each hexadecimal digit by 16 raised to the power of its position, counting from 0 on the right, and add up the results: 2F is 2 × 16 + 15 × 1 = 47. Hexadecimal is base 16, so it needs 16 digits, 0 to 9 and then A to F for ten to fifteen. This guide shows the conversion both ways, how hex maps onto binary and how hex color codes turn into red, green and blue values.

Hexadecimal digits and their decimal values

Hex Decimal Binary
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
A 10 1010
B 11 1011
C 12 1100
D 13 1101
E 14 1110
F 15 1111

Each hex digit stands for exactly four binary digits (bits), which is why programmers use hex as a short way to write binary: two hex digits make one byte, 00 to FF, or 0 to 255.

How to convert hex to decimal

Each position in a hex number is worth 16 times the one to its right, just as each place in a decimal number is worth 10 times more:

Position from the right Power of 16 Value
1st 160 1
2nd 161 16
3rd 162 256
4th 163 4,096
5th 164 65,536

Take 1A3:

  1. Write each digit’s decimal value: 1, A = 10 and 3.
  2. Multiply each one by its place value: 1 × 256 = 256, 10 × 16 = 160 and 3 × 1 = 3.
  3. Add the results: 256 + 160 + 3 = 419.

The last place is worth 1 because any nonzero number to the power of 0 is 1, one of the exponent rules that also explain why each place is 16 times the one before.

Common values to recognize:

Hex Decimal
10 16
20 32
40 64
64 100
80 128
FF 255
100 256
3E8 1,000
400 1,024
FFF 4,095
1000 4,096
FFFF 65,535

How to convert decimal to hex

Go the other way by dividing by 16 and keeping the remainders:

  1. Divide the number by 16 and write down the remainder, as a hex digit.
  2. Divide the quotient by 16 again, and repeat until the quotient is 0.
  3. Read the remainders from the last one to the first.

For 419: 419 ÷ 16 = 26, remainder 3; 26 ÷ 16 = 1, remainder 10 (A); 1 ÷ 16 = 0, remainder 1. Read upward, that gives 1A3.

How to convert hex to binary

Because 16 is 24, every hex digit turns into four bits on its own, with no arithmetic across digits: look each one up in the table above and write the groups side by side.

2F becomes 0010 (2) and 1111 (F): 00101111, or 101111 without the leading zeros. Going back, split the binary number into groups of four from the right and turn each group into one hex digit.

The binary calculator works like the hexadecimal one and shows each result in binary, decimal and hexadecimal too.

Hex color codes in decimal

A web color such as #0A518D is three hex numbers in a row. The W3C’s CSS Color specification defines the six-digit form: the first pair is red, the next pair green and the last pair blue, “where 00 represents the minimum value and ff (255 in decimal) represents the maximum”. Its own example: #00ff00 is the same color as rgb(0 255 0).

Color Hex Red Green Blue
White #FFFFFF 255 255 255
Black #000000 0 0 0
Lime #00FF00 0 255 0
Dark blue #0A518D 10 81 141

The three-digit form doubles each digit, so #123 is the same color as #112233.

Note: the letters A to F can be upper or lower case; 2f and 2F are the same number. The # of a color, or the 0x that marks a hex number in code, is not part of the number: leave it out when you type the digits into a calculator.

How to convert hex to decimal with the calculator

The hexadecimal calculator adds, subtracts, multiplies or divides two hex numbers and shows the result in binary, decimal and hexadecimal. To convert a single number, enter it as the 1st hexadecimal value, 0 as the 2nd and choose the sum: the decimal result is your number. For 0A518D it gives 676,237.

How to convert hex to decimal in 4 steps

  1. Write the decimal value of each hex digit, with A to F as 10 to 15.
  2. Number the positions from 0 on the right.
  3. Multiply each digit by 16 raised to its position and add the results.
  4. Check the answer in the hexadecimal calculator by adding 0 to your number.

Calculators in this article