Hex numbers may look tricky at first glance, but they’re actually pretty straightforward once you understand the system behind them.
In this article, we’ll break down what hexadecimal numbers are, how to convert them to and from decimal, and how to perform simple calculations using hex.
We also provide a calculator to simplify things.
Table of Contents
๐โโ๏ธ What Is a Hexadecimal Number?
The hexadecimal number system (also known as hex) is a base-16 system. This means it uses 16 unique symbols to represent values:
Hex digits: 0 1 2 3 4 5 6 7 8 9 A B C D E F
Decimal: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
So, for example:
A
in hex is equal to10
in decimalF
in hex is equal to15
in decimal
Hexadecimal is commonly used in computing and digital electronics because it’s more compact than binary and aligns well with byte boundaries.
Try the Hexadecimal Converter and Calculator
with support for five operations:
- Convert Only
- Add
- Subtract
- Multiply
- Divide
To use it enter two Hex numbers and select an operation.
๐งฎ How to Convert Hexadecimal to Decimal
To convert a hexadecimal number to a decimal, follow this simple method:
Step-by-step example: Convert 2F
to decimal
Each digit in a hex number represents a power of 16, starting from the right:
2F = (2 ร 16^1) + (15 ร 16^0)
= (2 ร 16) + (15 ร 1)
= 32 + 15
= 47 (decimal)
So, 2F
in hex is 47
in decimal.
๐งฎ How to Convert Decimal to Hexadecimal
To convert from decimal to hex, divide the number by 16 repeatedly and record the remainders:
Step-by-step example: Convert 47
to hex
- 47 รท 16 = 2 remainder 15 โ
F
- 2 รท 16 = 0 remainder 2 โ
2
Now reverse the remainders: 2F
So, 47
in decimal is 2F
in hex.
โ๏ธ โ Hexadecimal Addition Example
Let's add 1A
+ 2F
:
Step 1: Convert to decimal1A
= 262F
= 47
Sum = 26 + 47 = 73
Step 2: Convert result back to hex
73 รท 16 = 4 remainder 9 โ hex is 49
Answer: 1A + 2F = 49
โ๏ธ โ Hexadecimal Subtraction Example
Letโs subtract 2F - 1A
:
Step 1: Convert to decimal2F
= 471A
= 26
Difference = 47 - 26 = 21
Step 2: Convert back to hex
21 รท 16 = 1 remainder 5 โ hex is 15
Answer: 2F - 1A = 15
โจ Quick Tips for Working with Hex
- Use a calculator or spreadsheet when working with large hex values.
- Each hex digit maps to exactly 4 binary bits.
- Common in memory addresses, color codes (e.g.,
#FF5733
), and assembly programming.
๐ Summary
Decimal | Hex |
---|---|
10 | A |
15 | F |
26 | 1A |
47 | 2F |
255 | FF |
Hexadecimal math is just like decimalโonly with a different base. Once you're comfortable with the conversions, calculations like addition and subtraction become second nature.