Computer Science
Basic

Hexadecimal to Decimal

Convert a hexadecimal number to decimal.

Formula

N=∑i=0khi16iN = \sum_{i=0}^{k} h_i 16^i

Variables

h_iHex digits
iPosition

Example

0x1F = 31

How it works

A hexadecimal number is a base-16 number system, so each digit represents a value times a power of 16, just as each digit in decimal represents a value times a power of 10. This formula adds up every digit’s contribution from right to left: the rightmost digit is multiplied by 16^0, the next by 16^1, and so on. It works because positional numeral systems encode numbers by place value rather than by separate symbols alone.

When to use it

Use this when you need to read, check, or convert hexadecimal values into ordinary decimal numbers. It is common in programming, debugging memory addresses, color codes, and low-level data representation.

Worked example, step by step

Convert 0x2A3 to decimal N = 2×16^2 + A×16^1 + 3×16^0 A = 10, so N = 2×256 + 10×16 + 3×1 N = 512 + 160 + 3 N = 675

Common mistakes to avoid

  • Forgetting that A through F stand for 10 through 15
  • Using powers of 10 instead of powers of 16
  • Starting the place values from the left instead of the right

Did You Know?

Programmers love hexadecimal because each digit maps neatly to exactly four binary bits.

Share this formula

Reviewed & maintained by the FormulaWon editorial teamLast reviewed September 2026