How to use the hex to decimal converter
To use the converter, type a hex number in the Hexadecimal box and read its decimal value in the Decimal box.
- Type or paste a hex number such as 1A2B, 0x1A2B, #1A2B or 1A2Bh, in upper or lower case.
- Read the decimal value in the green box, which updates on every keystroke.
- Check the breakdown below, which shows each digit, its power of 16 and its share of the total.
- Type in the Decimal box instead to convert decimal to hex and see the divide-by-16 steps.
Tap any bit switch to flip that bit and watch both values change together. A link such as hextodecimal.net/?hex=FF opens the converter with that number filled in.
How to convert hex to decimal
To convert hex to decimal, multiply each hex digit by 16 raised to the power of its position, then add the products. Positions count from 0 on the right, so the place values run 1, 16, 256, 4,096 and 65,536.
decimal = dₙ×16ⁿ + … + d₂×16² + d₁×16¹ + d₀×16⁰
d = the value of each hex digit, from 0 to 15
n = the position of that digit, counted from 0 on the right- Replace each letter with its decimal value: A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15.
- Number the digit positions from right to left, starting at 0.
- Multiply each digit value by 16 raised to the power of its position.
- Add the products to get the decimal number.
Example 1: convert 2F to decimal
Hex 2F equals 47 in decimal, since the 2 sits in the 16s place and F (15) sits in the 1s place.
2F = 2×16¹ + F×16⁰
= 2×16 + 15×1
= 32 + 15
= 47Example 2: convert 1A2B to decimal
Hex 1A2B equals 6,699 in decimal, and its 4 digits use the place values 4,096, 256, 16 and 1.
1A2B = 1×16³ + A×16² + 2×16¹ + B×16⁰
= 1×4,096 + 10×256 + 2×16 + 11×1
= 4,096 + 2,560 + 32 + 11
= 6,699Example 3: convert 0x3E8 to decimal
Hex 0x3E8 equals 1,000 in decimal, and the 0x prefix only marks the number as hexadecimal without adding any value.
3E8 = 3×16² + E×16¹ + 8×16⁰
= 3×256 + 14×16 + 8×1
= 768 + 224 + 8
= 1,0004 common conversion mistakes
Four mistakes cause most wrong answers in hex to decimal conversion, and each one is easy to spot once you know it.
- Counting positions from 1 instead of 0, which makes every place value 16 times too large.
- Reading hex digits as decimal, so hex 20 comes out as 20 instead of the correct value, 32.
- Mixing up letter values, such as treating B as 12 when B equals 11.
- Ignoring the bit width, so FF reads as 255 when the data holds a signed 8-bit value of −1.
Place-value calculator
Step a digit up or downHex to decimal conversion table
Each hex digit stands for 4 bits, called a nibble, so 2 hex digits always make 1 byte (8 bits). The chart shows all 16 hex digits with their decimal and binary values, and each digit loads into the converter when you tap it.
- 000000
- 110001
- 220010
- 330011
- 440100
- 550101
- 660110
- 770111
- 881000
- 991001
- A101010
- B111011
- C121100
- D131101
- E141110
- F151111
| Hex | Decimal | Where it appears |
|---|---|---|
| 10 | 16 | The first two-digit hex number |
| 20 | 32 | The space character in ASCII |
| 41 | 65 | Capital A in ASCII |
| 7F | 127 | The largest signed 8-bit value |
| 80 | 128 | The lowest signed 8-bit value, −128 |
| FF | 255 | The largest value in 1 byte |
| 100 | 256 | The number of values 1 byte can hold |
| 400 | 1,024 | 1 kibibyte (KiB) |
| 7FFF | 32,767 | The largest signed 16-bit value |
| FFFF | 65,535 | The largest 16-bit value and the highest network port |
| 7FFFFFFF | 2,147,483,647 | The largest signed 32-bit value |
| FFFFFFFF | 4,294,967,295 | The largest 32-bit value |
Byte explorer
Slide, tap the grid or flip a bitHexadecimal and decimal number systems
Hexadecimal and decimal are positional number systems that differ in their base: hexadecimal is base 16, and decimal is base 10. Decimal is also called denary in UK schools and GCSE courses, so hex to denary means the same conversion.
Hexadecimal numbers (base 16)
A hexadecimal (hex) number uses 16 digits, 0 to 9 and A to F, and each place is worth 16 times the place to its right.
Programmers write memory addresses, colour codes and binary data in hex, since 1 hex digit maps to exactly 4 bits. Code and documents mark hex numbers with a 0x prefix (0xFF), a # sign (#FF0000) or an h suffix (FFh).
Decimal numbers (base 10)
A decimal number uses 10 digits, 0 to 9, and each place is worth 10 times the place to its right.
People count, price and measure in decimal, so software shows most numbers in decimal even when it stores them in binary.
Hex vs decimal compared
Hex and decimal differ in 7 main features, from the digits they use to the jobs they do.
| Feature | Hexadecimal | Decimal |
|---|---|---|
| Base | 16 | 10 |
| Digits | 0–9 and A–F | 0–9 |
| Place values | 1, 16, 256, 4,096 | 1, 10, 100, 1,000 |
| Bits per digit | Exactly 4 | About 3.32 |
| Largest 1-byte value | FF | 255 |
| Usual markers | 0x, #, h suffix | None |
| Main use | Memory, colours, machine code | Counting, prices, everyday maths |
Same number, four bases
Follows the converterHex fractions to decimal
To convert a hex fraction to decimal, multiply each digit after the point by a negative power of 16 and add the results to the whole part. The first place after the point is worth 1/16 (0.0625), and the second place is worth 1/256 (0.00390625).
1F.4 = 1×16¹ + F×16⁰ + 4×16⁻¹
= 16 + 15 + 4/16
= 31 + 0.25
= 31.25The converter above handles whole numbers, so work out the fractional part by hand and add it to the whole-number result.
Hex fraction calculator
Type a point, such as 1F.4Bar heights use a square-root scale so the small fraction places stay visible.
Signed hex numbers and two's complement
A signed hex number is negative when its top bit is 1, and computers store these negative integers in two's complement. To read the signed value, subtract 2ⁿ from the unsigned value, where n is the bit width of 8, 16, 32 or 64.
FFE6 unsigned = 65,510
Top bit is 1 → the value is negative
65,510 − 2¹⁶ = 65,510 − 65,536
Signed value = −26The converter shows the signed reading of every value next to the unsigned result. Pick 8, 16, 32 or 64 bits, or leave the size on Auto to use the smallest width that fits.
FF255 or −1One byte holds 255 unsigned or −1 as a signed 8-bit value.80128 or −128Only the top bit is set, so the signed 8-bit reading is the lowest possible value.7FFFFFFF2,147,483,647The largest signed 32-bit integer wraps to −2,147,483,648 when you add 1.FFFFFFFF4,294,967,295 or −1All 32 bits are set, and many APIs return this value as −1 to signal an error.
Two's complement ring
Drag the marker round the ringHex to decimal in programming
Most programming languages convert hex to decimal with one built-in function, and each example below turns the string "1A2B" into 6699.
Using the value from the converter above: 0x
Output:
Python
Python's int() function takes the base as its second argument and accepts the 0x prefix when the base is 16.
int("1A2B", 16) # 6699
int("0x1A2B", 16) # 6699
0x1A2B # 6699 (hex literal)JavaScript
JavaScript's parseInt() takes the radix as its second argument, and BigInt() converts values above 2⁵³ − 1 without rounding.
parseInt("1A2B", 16) // 6699
Number("0x1A2B") // 6699
BigInt("0xFFFFFFFFFFFFFFFF") // 18446744073709551615nC and C++
The C function strtol() and the C++ function std::stoi() take the base as their third argument, and strtoul() handles unsigned values above 2,147,483,647.
long n = strtol("1A2B", NULL, 16); // C: 6699
int m = std::stoi("1A2B", nullptr, 16); // C++: 6699Java
Java's Integer.parseInt() takes the radix as its second argument, and Long.parseLong() converts values too large for an int.
Integer.parseInt("1A2B", 16) // 6699
Long.parseLong("FFFFFFFF", 16) // 4294967295Excel
Excel's HEX2DEC function converts up to 10 hex digits and reads values from 8000000000 to FFFFFFFFFF as negative numbers.
=HEX2DEC("1A2B") → 6699
=HEX2DEC("FFFFFFFFFF") → -1How to convert decimal to hex
To convert decimal to hex, divide the number by 16 and write down the remainder, then repeat with the result until it reaches 0.
Read the remainders from last to first, and write the values 10 to 15 as the letters A to F.
6,699 ÷ 16 = 418 remainder 11 → B
418 ÷ 16 = 26 remainder 2 → 2
26 ÷ 16 = 1 remainder 10 → A
1 ÷ 16 = 0 remainder 1 → 1
Bottom to top: 1A2BDivide-by-16 ladder
Remainders read from the bottom upWhere hex to decimal conversion is used
Hex to decimal conversion turns up in 4 main areas: web colours, memory addresses, network addresses and character codes.
#1E90FFColour codesEach pair of digits is one channel: red 1E is 30, green 90 is 144 and blue FF is 255.0x7FFE5A10Memory addressesDebuggers and crash logs print addresses in hex, and 0x7FFE5A10 is 2,147,375,632 in decimal.2001:0DB8Network addressesIPv6 uses 8 groups of 4 hex digits and MAC addresses use 6 pairs; group 0DB8 is 3,512.U+00E9Unicode code pointsUnicode numbers every character in hex, and U+00E9 is é, code point 233 in decimal.