Menu
Coddy logo textTech

Decimal to Hex

Part of the Fundamentals section of Coddy's Assembly journey — lesson 12 of 45.

Converting decimal to hexadecimal is similar to converting decimal to binary — but instead of dividing by 2, you divide by 16.

The method: divide by 16 repeatedly, read remainders backward.

Step-by-step example: Convert 42 to hex

StepDivisionResultRemainder
142 ÷ 16210 (which is A in hex)
22 ÷ 1602

Read remainders from bottom to top: 2A

So 42 in decimal = 0x2A.

Example 2: Convert 255 to hex

StepDivisionResultRemainder
1255 ÷ 161515 (which is F in hex)
215 ÷ 16015 (F)

Read bottom to top: FF

So 255 in decimal = 0xFF.

Example 3: Convert 1000 to hex

StepDivisionResultRemainder
11000 ÷ 16628
262 ÷ 16314 (which is E in hex)
33 ÷ 1603

Read bottom to top: 3E8

So 1000 in decimal = 0x3E8.

Remainder reminder:

Remainder (0-15)Hex digit
0-90-9
10A
11B
12C
13D
14E
15F

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals