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 allGustafson’s Law
IntermediateIdeal scaled-workload speedup when more processors allow a larger parallel task in the same elapsed time. Here s is the serial fraction of the parallel execution time, not the single-processor fraction used in Amdahl’s law.
Hick–Hyman Law (Equal Choices)
IntermediateModels choice reaction time for n equally likely alternatives (n ≥ 1). This information-theoretic form assumes comparable, practised stimulus–response choices; it is not a universal law of menu browsing.
Fitts’s Law (Shannon Form)
IntermediateAn empirical model of aimed movement time: farther or narrower targets generally take longer to reach. Use D ≥ 0, W > 0 and fitted coefficients for the device and task.
Shannon 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.