A very convenient property of number bases is this: If A = BN, then each digit in a base A number will be exactly N digits in the base B number.
Since 16 = 24, each hexadecimal digit corresponds to exactly 4 bits.
Since 8 = 23, each octal digit corresponds to exactly 3 bits.
Hence, when converting between binary and either octal or hex, we can convert one octal or hex digit at a time. There is no long multiplication or division necessary. We simply convert one octal or hex digit at a time using Table 15.5, “Binary/Octal Conversion” or Table 15.6, “Binary/Hex Conversion”, or convert each group of 3 or 4 bits. With a little practice, you will have this table memorized and be able to "see" the bits in an octal or hex number at a glance.
Table 15.6. Binary/Hex Conversion
Binary | Hex |
---|---|
0000 | 0 |
0001 | 1 |
0010 | 2 |
0011 | 3 |
0100 | 4 |
0101 | 5 |
0110 | 6 |
0111 | 7 |
1000 | 8 |
1001 | 9 |
1010 | A |
1011 | B |
1100 | C |
1101 | D |
1110 | E |
1111 | F |
For this reason, we use octal or hexadecimal to represent values where we want to know the values of individual bits. Binary numbers tend to be long, so we represent them in hex or octal to save space. The lower the base, the more digits it takes to represent a typical value.
FFC3.216 = 1111 1111 1100 0011 . 00102
374.48 = 011 111 100 . 1002
When converting from binary to base 2N, we need to be careful. Always group bits beginning at the radix point and move outward. The number of bits may not be a multiple of N, so we may have to pad the leftmost group with leading 0s and the rightmost group with trailing 0s.
11001.112 = 011 001 . 1102 = 31.68
111010.0112 = 0011 1010 . 01102 = 3A.616
How many bits would each base 32 digit represent?
Perform the following conversions.
11FC.2_16 to binary
1100101111.01_2 to hex
773550.5_8 to binary
1001001010010.1_2 to octal