# Hexadecimal to Octal and Vice Versa

Convert Hexadecimal number to Octal - $(FD56.52A)_{16}$ to octal

My answer - $(176526.2452)_8$

Convert Octal to Hexadecimal $(37.27)_8$

My answer - $(1F.5C)_{16}$.

Correct or incorrect?

First of all, use ${inline formula}$ and $${paragraph formula}$$ to typeset mathematics, to get proper subscripts.

One strategy is to just convert to decimal and back, but a much better strategy is to remember that in hexadecimal each digit corresponds to four binary digits ($2^4=16$) and in octal each digit is three bits ($2^3=8$).

$$({\rm FD56.52A})_{16} = (1111'1101'0101'0110\,.0101'0010'1010)_2$$

Then we regroup to three digits and pad with zeros:

$$(001'111'110'101'010'110\,.010'100'101'010)_2 = (176526.2452)_8$$

You can use this method the other around way too.

The easiest way to do that is perhaps to go trought binary

$FD56.52A_{16}= 1111\ 1101\ 0101\ 0110.0101\ 0010\ 1010_2$

and then to form groups of 3 digits left and right from the decimal point and padding with zeros the extremes if necessary

$FD56.52A16_{16}= 001\ 111\ 110\ 101\ 010\ 110.010\ 100\ 101\ 010_2 =176526.2452_8$