To convert from binary to hexadecimal we can use the properties of the numbers themselves. Consider the following table of numbers:
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
For example using the number 11001011101011:
- We show it as 11 / 0010 / 1110 / 1011
- Pad the left set as 0011
- Convert each set of four to give 32EB
Another example: Convert the binary number 100110101101010 to hexadecimal.
- Express the binary number as 100 / 1101 / 0110 / 1010.
- Pad the leftmost set to give 0100.
- Convert each set to a single hex digit giving 4D6A.
Next: Hexadecimal to Binary