How to Convert Hex to Decimal
Converting hexadecimal to decimal uses positional notation — the same principle behind how decimal numbers work, but with base 16 instead of base 10. Each digit in a hex number has a positional value that is a power of 16, and the decimal result is the sum of all digit values multiplied by their positional weights.
The Positional Notation Formula
The general formula for converting a hex number with digits to decimal is:
Where is the decimal value of the hex digit at position (counting from the right, starting at 0). Hex letters map to: A=10, B=11, C=12, D=13, E=14, F=15.
Step-by-Step Conversion Method
Follow these steps to convert any hexadecimal number to decimal by hand:
Step 1: Write down the hex number
Remove any prefix such as 0x or #. For example, 0x1A3F becomes 1A3F.
Step 2: Assign powers of 16 to each digit from right to left
The rightmost digit gets 160 = 1, the next gets 161 = 16, then 162 = 256, 163 = 4,096, and so on.
Step 3: Convert hex letters (A-F) to their decimal values
Replace A with 10, B with 11, C with 12, D with 13, E with 14, and F with 15. Digits 0-9 remain unchanged.
Step 4: Multiply each digit by its power of 16
Calculate the product of each digit's decimal value and its corresponding power of 16.
Step 5: Sum all products
Add all the products together. The result is the decimal equivalent of the hexadecimal number.
Powers of 16 Reference
Memorizing the first few powers of 16 makes hex-to-decimal conversion much faster:
| Power | Value | Meaning |
|---|---|---|
| 160 | 1 | Ones place |
| 161 | 16 | Sixteens place |
| 162 | 256 | Two-fifty-sixes place |
| 163 | 4,096 | Four-thousand-ninety-sixes place |
| 164 | 65,536 | 16-bit boundary |
| 168 | 4,294,967,296 | 32-bit boundary |
Hex to Decimal Conversion Table
This complete hex to decimal conversion table covers all 256 byte values from 00 to FF. Each row shows the hexadecimal value, its decimal equivalent, binary representation, and octal equivalent.
Quick Reference (Single Hex Digits 0-F):
| Hex | Decimal | Binary | Octal |
|---|---|---|---|
| 00 | 0 | 00000000 | 000 |
| 01 | 1 | 00000001 | 001 |
| 02 | 2 | 00000010 | 002 |
| 03 | 3 | 00000011 | 003 |
| 04 | 4 | 00000100 | 004 |
| 05 | 5 | 00000101 | 005 |
| 06 | 6 | 00000110 | 006 |
| 07 | 7 | 00000111 | 007 |
| 08 | 8 | 00001000 | 010 |
| 09 | 9 | 00001001 | 011 |
| 0A | 10 | 00001010 | 012 |
| 0B | 11 | 00001011 | 013 |
| 0C | 12 | 00001100 | 014 |
| 0D | 13 | 00001101 | 015 |
| 0E | 14 | 00001110 | 016 |
| 0F | 15 | 00001111 | 017 |
This table covers all possible single-byte hexadecimal values (00-FF) with their decimal, 8-bit binary, and octal equivalents. For values beyond FF, apply the same positional notation formula to each hex digit.
Hex to Decimal Conversion Examples
Below are worked examples showing the hex to decimal conversion process step by step, from simple single-digit values to multi-byte numbers.
Convert 2F to Decimal
Hex input: 2F
1.
2.
3.
Result: 2F16 = 4710
Convert FF to Decimal
Hex input: FF
1.
2.
3.
Result: FF16 = 25510 — the maximum value of an unsigned byte.
Convert 1A3F to Decimal
Hex input: 1A3F
1.
2.
3.
4.
5.
Result: 1A3F16 = 6,71910
Convert DEADBEEF to Decimal
Hex input: DEADBEEF (a famous "hexspeak" debug marker)
1.
2.
3.
4.
5.
6.
7.
8.
Result: DEADBEEF16 = 3,735,928,55910 — a 32-bit value commonly used to mark uninitialized memory.
Convert Color Code #3A7BD5 to Decimal
Hex input: #3A7BD5 (a shade of blue)
Full value:
Per channel (each pair is one byte):
Red:
Green:
Blue:
RGB result: (58, 123, 213). You can also convert hex color codes using our hex to RGB converter.
Hex to Decimal in Programming
Most programming languages provide built-in functions for converting hexadecimal strings to decimal integers. Here are examples in popular languages.
Python
# Convert hex string to decimal integer
hex_value = "FF"
decimal_value = int(hex_value, 16)
print(decimal_value) # 255
# Using 0x prefix literal
value = 0xFF
print(value) # 255
# Decimal to hex (reverse)
print(hex(255)) # '0xff'
print(format(255, 'X')) # 'FF'
# Large hex values
big_hex = "DEADBEEF"
big_decimal = int(big_hex, 16)
print(big_decimal) # 3735928559JavaScript
// Convert hex string to decimal number
const hexValue = "FF";
const decimalValue = parseInt(hexValue, 16);
console.log(decimalValue); // 255
// Using 0x prefix literal
const value = 0xFF;
console.log(value); // 255
// Decimal to hex (reverse)
console.log((255).toString(16).toUpperCase()); // 'FF'
// For values larger than 2^53, use BigInt
const bigHex = "DEADBEEFDEADBEEF";
const bigDec = BigInt("0x" + bigHex);
console.log(bigDec.toString()); // '16045690984833335023'C
#include <stdio.h>
#include <stdlib.h>
int main() {
// Convert hex string to decimal using strtol
const char *hexStr = "FF";
long decimal = strtol(hexStr, NULL, 16);
printf("%ld\n", decimal); // 255
// Using hex literal
int value = 0xFF;
printf("%d\n", value); // 255
// Larger value
unsigned long big = strtoul("DEADBEEF", NULL, 16);
printf("%lu\n", big); // 3735928559
return 0;
}Applications of Hex to Decimal Conversion
- Memory addresses — Debugging tools display memory addresses in hex (e.g., 0x7FFF5FBFF8AC). Converting to decimal helps with offset calculations and pointer arithmetic.
- Web color codes — CSS hex colors like #FF5733 encode RGB channel values as decimal 0-255. Converting hex pairs to decimal reveals the actual color intensity: FF = 255 (max red), 57 = 87 (moderate green), 33 = 51 (low blue).
- MAC addresses — Network interface identifiers (00:1A:2B:3C:4D:5E) use hex notation. Converting to decimal is needed for certain network administration tasks and database queries.
- Unicode code points — Characters are identified by hex code points (e.g., U+0041 for the letter "A"). Converting U+0041 to decimal gives 65, which is the ASCII value.
- Cryptographic hashes — Hash values like SHA-256 are displayed in hex. Converting individual bytes to decimal is useful for checksum verification and statistical analysis.
Related Converters
Explore our other number system and encoding converters for related tasks:
- Hex to Binary Converter — Convert hexadecimal numbers to binary with 4-bit group visualization
- Hex to RGB Converter — Convert hex color codes to RGB values for web design
- Hex to Text Converter — Decode hexadecimal strings into readable ASCII text
- Binary to Decimal Converter — Convert binary numbers to decimal representation
- Binary to Octal Converter — Convert binary numbers to octal (base-8) values
For a deep dive into how hexadecimal works and its role in computing, read our comprehensive guide: How Does Hexadecimal Work: Complete Guide to Base-16 Numbers.