Menu
Coddy logo textTech

Hex to Decimal

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

Hexadecimal (base 16) works the same way as binary and decimal — each position has a place value. In hex, each position is a power of 16.

Place values in hex:

PositionPower of 16Decimal value
Rightmost16⁰1
Next16¹16
Next16²256
Next16³4096

Hex digit values to remember:

HexDecimal
0-90-9
A10
B11
C12
D13
E14
F15

Example 1: Convert <strong>0x2A</strong> to decimal

PositionHex digitPlace valueCalculation
Left2162 × 16 = 32
RightA (10)110 × 1 = 10
Total  32 + 10 = 42

So 0x2A = 42 in decimal.

Example 2: Convert <strong>0xFF</strong> to decimal

PositionHex digitPlace valueCalculation
LeftF (15)1615 × 16 = 240
RightF (15)115 × 1 = 15
Total  240 + 15 = 255

So 0xFF = 255 in decimal.

Example 3: Convert <strong>0x3E8</strong> to decimal

PositionHex digitPlace valueCalculation
Left32563 × 256 = 768
MiddleE (14)1614 × 16 = 224
Right818 × 1 = 8
Total  768 + 224 + 8 = 1000

So 0x3E8 = 1000 in decimal.

The formula:

For a hex number with digits ... d₂ d₁ d₀:

Value = (... + d₂ × 16² + d₁ × 16¹ + d₀ × 16⁰)

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