Binary to Hexadecimal
To convert from binary to hexadecimal we can use the properties of the numbers themselves. Consider the following table of numbers.
DenaryBase 10 |
Binary Base 2 |
Hexadecimal Base 16 |
0 | 0000 | 0 |
1 | 0001 | 1 |
2 | 0010 | 2 |
3 | 0011 | 3 |
4 | 0100 | 4 |
5 | 0101 | 5 |
6 | 0110 | 6 |
7 | 0111 | 7 |
8 | 1000 | 8 |
9 | 1001 | 9 |
10 | 1010 | A |
11 | 1011 | B |
12 | 1100 | C |
13 | 1101 | D |
14 | 1110 | E |
15 | 1111 | F |
We can see that each hexadecimal digit maps to a unique sequence of four bits. Using this property we can convert binary to hex by
- Starting from the right chopping the binary number into sets of 4 bits
- If there are fewer than 4 bits left pad them out with zeros at the left
- Convert each set of 4 bits into the appropriate hexadecimal digit
Next: Binary to Hex Example