|  | 6.2 | Hexadecimal Numbers
| 6.2.5 | Methods for working with hexadecimal and binary numbers

Converting binary to hexadecimal and hexadecimal to binary is an easy conversion. The reason is that base16(hexadecimal) is a power of base 2(binary). Every four binary digits (bits) are equal to one hexadecimal digit. The conversion looks like this:

Binary |  | Hex | Binary |  | Hex
0000 | = | 0 | 1000 | = | 8
0001 | = | 1 | 1001 | = | 9
0010 | = | 2 | 1010 | = | A
0011 | = | 3 | 1011 | = | B
0100 | = | 4 | 1100 | = | C
0101 | = | 5 | 1101 | = | D
0110 | = | 6 | 1110 | = | E
0111 | = | 7 | 1111 | = | F

So if we have a binary number that looks like 01011011, we break it into two groups of four bits. These look like this: 0101 and 1011. When you convert these two groups to hex, they look like 5 and B. So converting 01011011 to hex is 5B. To convert hex to binary do the opposite. Convert hex AC to binary. First convert hex A which is 1010 binary and then convert hex C which is 1100 binary. So the conversion is hex AC is 10101100 binary.
No matter how large the binary number, you always apply the same conversion. Start from the right of the binary number and break the number into groups of four. If at the left end of the number it doesn't evenly fit into a group of four, add zeros to the left end until it is equal to four digits (bits). Then convert each group of four to its hex equivalent. Here is an example:

100100100010111110111110111001001 | converts to:
0001 | 0010 | 0100 | 0101 | 1111 | 0111 | 1101 | 1100 | 1001 | converts to:
1 | 2 | 4 | 5 | F | 7 | D | C | 9 | so:
100100100010111110111110111001001 Binary = 1245F7DC9 hex

As stated before hex works in exactly the opposite way. For every one hex digit, you convert it to four binary digits (bits). For example:

> AD46BF | converts to:
> |  |  | A | D | 4 | 6 | B | F | converts to:
> |  |  | 1010 | 1101 | 0100 | 0110 | 1011 | 1111 | so:
> AD46BF hex converts to 101011010100011010111111 binary

That is the conversion for binary to hexadecimal and from hexadecimal to binary.