TAOCP 4.1 Exercise 9
Each octal digit corresponds to three binary digits, and each hexadecimal digit corresponds to four binary digits.
Section 4.1: Positional Number Systems
Exercise 9. ▶ [**] [15] Change the following octal numbers to hexadecimal notation, using the hexadecimal digits 0, 1, . . ., 9, A, B, C, D, E, F: 12; 5655; 2530276; 76545336; 3726755.
Verified: yes
Solve time: 2m21s
Each octal digit corresponds to three binary digits, and each hexadecimal digit corresponds to four binary digits. Therefore, to convert an octal number to hexadecimal, we first replace each octal digit by its 3-bit binary equivalent, then group the resulting binary string into blocks of four bits from the right, padding on the left with leading zeros if necessary. Each 4-bit block is then converted to a hexadecimal digit.
$$ 12_8 = 001,010_2 = 1010_2 = A_{16}. $$
For $5655_8$,
$$ 5655_8 =101,110,101,101_2 =101110101101_2. $$
Grouping into 4-bit blocks from the right,
$$ 1011,1010,1101_2. $$
Since
$$ 1011_2=B,\qquad 1010_2=A,\qquad 1101_2=D, $$
we obtain
$$ 5655_8=BAD_{16}. $$
For $2530276_8$,
$$ 2530276_8 =010,101,011,000,010,111,110_2 =010101011000010111110_2. $$
Padding with one leading zero and grouping into 4-bit blocks gives
$$ 0101,0101,1000,0101,1110_2. $$
Therefore
$$ 0101_2=5,\quad 0101_2=5,\quad 1000_2=8,\quad 0101_2=5,\quad 1110_2=E, $$
hence
$$ 2530276_8=5585E_{16}. $$
For $76545336_8$,
$$ 76545336_8 =111,110,101,100,101,011,011,110_2 =111110101100101011011110_2. $$
Grouping into 4-bit blocks,
$$ 1111,1010,1100,1010,1101,1110_2. $$
Thus
$$ 1111_2=F,\quad 1010_2=A,\quad 1100_2=C,\quad 1010_2=A,\quad 1101_2=D,\quad 1110_2=E, $$
and therefore
$$ 76545336_8=FACADE_{16}. $$
For $3726755_8$,
$$ 3726755_8 =011,111,010,110,111,101,101_2 =011111010110111101101_2. $$
Padding with three leading zeros and grouping into 4-bit blocks gives
$$ 0011,1110,1011,0111,1011_2. $$
Hence
$$ 0011_2=3,\quad 1110_2=E,\quad 1011_2=B,\quad 0111_2=7,\quad 1011_2=B, $$
so
$$ 3726755_8=3EB7B_{16}. $$
Therefore the required hexadecimal representations are
$$ \boxed{ \begin{aligned} 12_8 &= A_{16},\ 5655_8 &= BAD_{16},\ 2530276_8 &= 5585E_{16},\ 76545336_8&= FACADE_{16},\ 3726755_8 &= 3EB7B_{16}. \end{aligned} } $$