Binary/Octal/Hexadecimal Conversions

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.5. Binary/Octal Conversion

BinaryOctal
0000
0011
0102
0113
1004
1015
1106
1117

Table 15.6. Binary/Hex Conversion

BinaryHex
00000
00011
00102
00113
01004
01015
01106
01117
10008
10019
1010A
1011B
1100C
1101D
1110E
1111F

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

Note

When converting large numbers from decimal to binary or from binary to decimal, smart people first convert to hexadecimal. This greatly reduces the number of steps in long multiplication or long division. People who are paid by the hour to do manual number conversions are not advised to use this shortcut.
Practice

Note

Be sure to thoroughly review the instructions in Section 2, “Practice Problem Instructions” before doing the practice problems below.
  1. How many bits would each base 32 digit represent?

  2. Perform the following conversions.

    1. 11FC.2_16 to binary

    2. 1100101111.01_2 to hex

    3. 773550.5_8 to binary

    4. 1001001010010.1_2 to octal