LogicGates.org Open the simulatorSimulator

Hex to decimal converter

Type a hexadecimal number to get its decimal value, or switch direction for decimal to hex. Every conversion shows its working: place values one way, repeated division by 16 the other.

Digits 0 to 9 and A to F, upper or lower case. A leading 0x, # or $ is ignored, and so are spaces.

Decimal 48,879 BEEF in hex is 1011 1110 1110 1111 in binary

Working: each digit times its place value

Digit Value Place Place value Digit × place
B 11 16³ 4,096 45,056
E 14 16² 256 3,584
E 14 16¹ 16 224
F 15 16⁰ 1 15
Sum 48,879

11×16³ + 14×16² + 14×16¹ + 15×16⁰
= 45,056 + 3,584 + 224 + 15
= 48,879

What hexadecimal is

Hexadecimal, or hex, is base 16. Decimal runs out of digits at 9 and carries into the tens column; hex keeps going with six letters, A to F for ten to fifteen, and only carries at sixteen. So 10 in hex is sixteen, 100 is 16 × 16 = 256, and FF is the largest two digit value, 255.

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

Hex to decimal chart: 00 to FF

Every one-byte value. Find the first hex digit down the side and the second along the top: 7F is row 7, column F, which is 127. The top row is 0 to 15, and each row down adds 16.

Decimal values of the hex bytes 00 to FF
First digit 0123456789ABCDEF
0 0123456789101112131415
1 16171819202122232425262728293031
2 32333435363738394041424344454647
3 48495051525354555657585960616263
4 64656667686970717273747576777879
5 80818283848586878889909192939495
6 96979899100101102103104105106107108109110111
7 112113114115116117118119120121122123124125126127
8 128129130131132133134135136137138139140141142143
9 144145146147148149150151152153154155156157158159
A 160161162163164165166167168169170171172173174175
B 176177178179180181182183184185186187188189190191
C 192193194195196197198199200201202203204205206207
D 208209210211212213214215216217218219220221222223
E 224225226227228229230231232233234235236237238239
F 240241242243244245246247248249250251252253254255

The same bytes as characters are in the ASCII table, and a byte read as a signed number (80 to FF as −128 to −1) is covered by two's complement.

Printable hex to decimal chart

The same 00 to FF grid as one black-on-white image, for printing or a slide.

Hex to decimal conversion chart: a 16 by 16 grid of every two-digit hexadecimal value from 00 to FF with its decimal equivalent from 0 to 255, rows by first hex digit and columns by second Click to download: Hex to decimal chart

Why programmers use hex

  • Four bits per digit. Sixteen is 24, so each hex digit is exactly one group of four bits, a nibble. Converting to binary is a lookup, digit by digit, with no arithmetic; the hex to binary converter shows it.
  • A byte is two digits. Eight bits always fit in 00 to FF, so memory dumps, network packets and file formats line up in neat pairs. The same byte in decimal takes one to three digits and does not line up.
  • Colours. A CSS colour such as #1E90FF is three bytes: red 1E = 30, green 90 = 144 and blue FF = 255.
  • Memory addresses and masks. An address like 0x7FFF0010 or a mask like 0xFF00 is easier to read and check in hex, because you can see which bits are set without converting anything.

Worked examples

1A3 to decimal

1×16² + A×16¹ + 3×16⁰
= 1×256 + 10×16 + 3×1
= 256 + 160 + 3
= 419

A is 10, so the middle digit is worth 10 × 16. Try it

1000 to hex

1000 ÷ 16 = 62 remainder 8
62 ÷ 16 = 3 remainder 14 (E)
3 ÷ 16 = 0 remainder 3

Read the remainders upwards: 3E8. Try it

Powers of 16 are the place values, the way powers of 10 are in decimal. The first few are worth knowing:

PowerValueIn hex
16⁰ 1 1
16¹ 16 10
16² 256 100
16³ 4,096 1000
16⁴ 65,536 10000
16⁵ 1,048,576 100000
16⁶ 16,777,216 1000000
16⁷ 268,435,456 10000000
16⁸ 4,294,967,296 100000000

To add, subtract or multiply hex numbers directly, with carries shown, use the hex calculator. For signed values in a fixed number of bits, see two's complement and the binary converter.

Questions

What is FF in decimal?

FF is 255. The left F is worth 15 × 16 = 240 and the right F is worth 15 × 1 = 15, and 240 + 15 = 255. It is the largest value one byte can hold, which is why it turns up in colour codes and masks.

How do I convert hex to decimal by hand?

Number the digits from the right starting at 0. Multiply each digit by 16 to the power of its position, using A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15, then add the results. For 1A3 that is 1×256 + 10×16 + 3×1 = 419.

How do I convert decimal to hex?

Divide the number by 16 and write down the remainder, then divide the quotient by 16 again, and keep going until the quotient is 0. Write each remainder as a hex digit (10 is A, 15 is F) and read them from the last one to the first. 1000 gives remainders 8, 14 and 3, so it is 3E8.

What does 0x mean in front of a number?

It marks the number as hexadecimal in C, JavaScript, Python and most other languages, so 0x10 is sixteen and not ten. CSS writes a # instead for colours, and some assemblers use a trailing h or a leading $. The converter accepts 0x, # and $ and ignores them.

How big a number can this convert?

Up to 64 digits of either base, which is 256 bits in hex. The arithmetic uses whole numbers of any size, so nothing is rounded the way it would be in a spreadsheet past about 15 digits. Negative numbers and fractions are not converted here; a negative number needs a fixed width, which the two's complement page covers.

Why is hexadecimal base 16?

Because 16 is 2 to the power 4, so one hex digit stands for exactly four bits. That makes converting between hex and binary a matter of looking up each digit, while still writing a byte in two characters instead of eight.