Skip to content
Mediawand

Decimal to Hexadecimal: How to Convert, with Examples

Updated November 7, 2026

To convert decimal to hexadecimal, divide by 16 again and again, write down each remainder, then read the remainders from last to first. Remainders from 10 to 15 become the letters A to F. So 255 becomes FF, and 2026 becomes 7EA.

Convert decimal to hex

What hexadecimal is

Everyday numbers are decimal, or base 10, which uses ten digits from 0 to 9. Hexadecimal is base 16, so it needs sixteen digits. It uses 0 to 9, then the letters A to F for the values 10 to 15.

In decimal, each place is worth ten times the one to its right: ones, tens, hundreds. In hex, each place is worth sixteen times as much: 1, 16, 256, 4096.

DecimalHexBinary
000000
110001
220010
330011
440100
550101
660110
770111
881000
991001
10A1010
11B1011
12C1100
13D1101
14E1110
15F1111

How to convert decimal to hex

The method works for any whole number.

  1. 1Divide the number by 16.
  2. 2Write down the remainder, using A to F for 10 to 15.
  3. 3Divide the whole-number answer by 16 again.
  4. 4Keep going until the answer is 0.
  5. 5Read the remainders from last to first.

Worked example: 2026

Reading the remainders from the bottom up gives 7, E and A, so 2026 in hex is 7EA.

DivisionAnswerRemainderHex digit
2026 ÷ 1612610A
126 ÷ 16714E
7 ÷ 16077

Worked example: 255

255 ÷ 16 is 15 with a remainder of 15, which gives F. Then 15 ÷ 16 is 0 with a remainder of 15, which gives another F. So 255 is FF, the largest value that fits in one byte.

How to convert hex back to decimal

Multiply each digit by its place value, then add the results. For 7EA, that's 7 × 256 = 1792, E (14) × 16 = 224, and A (10) × 1 = 10. Adding them gives 2026, which matches the example above.

A smaller example: 2F is 2 × 16 + 15, which is 47. To skip the sums, use the hex to decimal converter.

Why programmers use hex

One hex digit stands for exactly four binary digits, so hex is a compact way to write binary. One byte is eight binary digits, which is always two hex digits. The binary number 0010 1111 splits into 0010 and 1111, which gives 2F.

You'll see hex in web colors, memory addresses and raw data. In the color #FF8800, each pair is one channel: FF is 255 red, 88 is 136 green and 00 is 0 blue.

Code often marks hex with 0x, as in 0xFF, so that it can't be mistaken for a decimal number.

Quick reference

These values come up often. For anything else, use the decimal to hex converter.

DecimalHex
10A
1610
10064
255FF
256100
10003E8
40961000
65535FFFF

Tools for this

Loading tools…