Hexadecimal to Decimal
Convert a hex number to decimal by positional weights.
Formula
Variables
Example
0x1F = 31
How it works
A hexadecimal number is a base-16 number system, so each digit represents a value multiplied by a power of 16 depending on its position. The rightmost digit has weight 16^0, the next has weight 16^1, then 16^2, and so on; the formula adds these weighted values to produce the decimal total. This works because positional numeral systems encode numbers by place value, just like decimal uses powers of 10.
When to use it
Use this when you need to convert hex values into ordinary decimal numbers, such as reading memory addresses, color codes, machine-level data, or programming outputs. It is also useful in computer science classes when comparing base-16 and base-10 representations.
Worked example, step by step
Convert 0x2A to decimal 0x2A = (2 × 16^1) + (A × 16^0) A = 10, so 0x2A = (2 × 16) + (10 × 1) = 32 + 10 = 42
Common mistakes to avoid
- Forgetting that A, B, C, D, E, and F mean 10 through 15
- Using the wrong position powers, especially starting from 16^1 instead of 16^0
- Treating the digits as separate decimal numbers instead of weighted place values
Did You Know?
Hexadecimal packs four bits per digit, which is why colours and memory addresses are written in hex.
Share this formula
More in Computer Science
View allShannon Entropy
AdvancedAverage information content of a random source (bits).
Master Theorem (form)
AdvancedAnalyzes running time of divide-and-conquer algorithms.
Hamming Distance
AdvancedNumber of positions at which two strings differ.
Bits to Represent n
BasicMinimum number of bits to represent n distinct values.
Binary to Decimal
BasicConverts a binary number to decimal.
Nodes in a Full Binary Tree
IntermediateTotal nodes in a perfect binary tree of height h.