Hexadecimal facts for kids
The hexadecimal numeral system, often called "hex", is a special way to count using 16 different symbols. Our usual way of counting is called the decimal system (base 10), which uses ten symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
Hexadecimal uses these same ten numbers, plus six extra symbols. Since we don't have single numbers for values greater than nine, we use letters from the English alphabet: A, B, C, D, E, and F.
- Hexadecimal A means 10 in decimal.
- Hexadecimal F means 15 in decimal.
Most people use the decimal system, probably because we have ten fingers. But computers work differently. They only understand "on" or "off" signals, which are called binary digits (or bits). A binary number is just a string of zeros and ones, like 11011011.
To make it easier for engineers to work with these long strings of bits, they group them. In the past, they sometimes grouped bits in threes. Three bits can represent eight numbers (0 to 7). This system is called octal.
As computers became more powerful, it was better to group bits in fours. Four bits can represent 16 different values instead of eight. The word "hex" means 6, and "decimal" means 10, so "hexadecimal" means 16. In computer jargon, four bits are called a nibble. A nibble is like one hexadecimal digit (0-9 or A-F). Two nibbles make a byte (which is 8 bits). Computers often work with bytes or groups of bytes (like 16, 32, or 64 bits). Hexadecimal makes it much simpler to write down these large binary numbers.
To make sure people know a number is hexadecimal and not decimal or octal, it's sometimes written with an "h" after it or "0x" before it. For example, 63h and 0x63 both mean 63 in hexadecimal.
Contents
Understanding Hexadecimal Values
Hexadecimal is useful because it connects easily to the binary system. Each single digit in hexadecimal stands for four digits in binary. This is why it's so helpful for computers.
In the decimal system, each digit's place has a value: ones, tens, hundreds, and so on. In hexadecimal, each digit can have 16 different values. So, the places are the one's place, the sixteen's place, and the 256's place (because 16 x 16 = 256).
- 1h = 1 in decimal
- 10h = 16 in decimal
- 100h = 256 in decimal
Here's a table showing how hexadecimal numbers compare to binary, octal, and decimal:
|
How to Convert Numbers
Binary to Hexadecimal
To change a binary number into hex, you group the binary digits. Start from the right side and make groups of four digits. Then, use the table above to change each group of four binary digits into its hexadecimal symbol (0-9 or A-F).
To change from hexadecimal back to binary, you do the opposite. Each hex digit becomes a group of four binary digits.
Binary | Groupings | Hex | |||
---|---|---|---|---|---|
01100101 | 0110 | 0101 | 65 | ||
010010110110 | 0100 | 1011 | 0110 | 4B6 | |
1101011101011010 | 1101 | 0111 | 0101 | 1010 | D75A |
If your binary number doesn't have a number of bits that is a multiple of 4, you add zeros to the front until it does.
- Binary 110 becomes 0110, which is 6 in Hex.
- Binary 010010 becomes 00010010, which is 12 in Hex.
Hexadecimal to Decimal
To change a hexadecimal number to a decimal number, you can use this method:
- Find the decimal value for each hexadecimal digit. Remember: A=10, B=11, C=12, D=13, E=14, F=15.
- Start with the digit on the far right (the "one's" place). Multiply its decimal value by 1.
- Move to the next digit to the left (the "sixteen's" place). Multiply its decimal value by 16.
- For the third digit from the right, multiply its decimal value by 162 (which is 16 x 16 = 256).
- Keep going for each digit, multiplying by the next power of 16 (4096, 65536, etc.).
- Add all these results together to get your final decimal number.
Place Value | ||||||
---|---|---|---|---|---|---|
6th | 5th | 4th | 3rd | 2nd | 1st | |
Value | 1048576 (165) | 65536 (164) | 4096 (163) | 256 (162) | 16(161) | 1 (160) |
Example: Let's convert 5Fh to decimal.
- F is the rightmost digit. Its decimal value is 15. So, 15 x 1 = 15.
- 5 is the next digit to the left. Its decimal value is 5. So, 5 x 16 = 80.
- Now, add them up: 15 + 80 = 95.
So, 5Fh is 95 in decimal.
Example: Let's convert 3425h to decimal.
- 5 (rightmost digit): 5 x 1 = 5
- 2 (next digit): 2 x 16 = 32
- 4 (next digit): 4 x 256 = 1024
- 3 (leftmost digit): 3 x 4096 = 12288
- Add them all: 5 + 32 + 1024 + 12288 = 13349.
So, 3425h is 13349 in decimal.
Related pages
Images for kids
See also
In Spanish: Sistema hexadecimal para niños