Octal Multiplication

arithmetic

I'm taking an intro CS course for Math and my teacher has a horrible habit of only providing 1 example for each problem and then moving on – without even breaking down that example. Hence why I'm here.

I am trying to figure out Hexadecimal and Octal multiplication. I really couldn't understand the logic behind it. So for example, I have a problem like:

34 * 36

So 6 * 4 = 24, which is 8 * 3. But what do I put in the answer row and the carry row?

What pattern do I follow when it comes to performing arithmetic for numbers with bases 8, 16, etc.?

Best Answer

Octal multiplication is not that different from regular multiplication. I'm going to work through a different example ($25·47$) in base 10 and then in base 8 so that you can see where the similarities and the differences are.

First, what does $25·47$ really mean? In base 10, 25 means $2·10 + 5$ and 47 means $4·10+7$. So we're really doing: $$(2·10+5)(4·10+7).$$

Ordinary algebra tells us that $(a+b)(c+d) = ac + ad + bc + bd$, so we can rewrite this as

$$\begin{array}{lll} \text{hundreds} & \text{tens} & \text{units} \\ \hline \color{darkblue}{2·4}·10^2 & + \color{purple}{2}·10·\color{purple}{7} + \color{purple}{5·4}·10 & + \color{maroon}{5·7} = \\ \color{darkblue}{2·4}·10^2 & + \color{purple}{(2·7+5·4)}·10 & + \color{maroon}{5·7} \end{array} $$

The three terms here represent the hundreds (blue), tens (purple), and units (red) columns. Now we need to do the carrying.

$\color{maroon}{5·7} = 3·10+5$, so we move the three tens from the units column into the next column to the left: $$\begin{array}{lll} \text{hundreds} & \text{tens} & \text{units} \\ \hline \color{darkblue}{2·4}·10^2 & + \color{purple}{(2·7+5·4\color{maroon}{+3})}·10 & + \color{maroon}{5}\end{array}$$

and then $\color{purple}{2·7+5·4 + \color{maroon}{3}} = 3·10+7$, so we move the three tens left from the tens column:

$$\begin{array}{lll} \text{hundreds} & \text{tens} & \text{units} \\ \hline \color{darkblue}{(2·4\color{purple}{+3})}·10^2 & + \color{purple}{7}·10 & + \color{maroon}{5}\end{array}$$

Finally, $ \color{darkblue}{2·4\color{purple}{+3}} = 1·10+1$, so we move the ten left from the hundreds column into a new column:

$$\begin{array}{llll} \text{thousands} & \text{hundreds} & \text{tens} & \text{units} \\ \hline 1 ·10^3 & + \color{darkblue}{1}·10^2 & + \color{purple}{7}·10 & + \color{maroon}{5}\end{array}$$

And in base 10, we abbreviate this to just $$1 \color{darkblue}{1} \color{purple}{7} \color{maroon}{5}$$

which is the answer: $25·47 = 1125$. Now make sure you followed that carefully, because we're going to do it over in base 8.


What does $25·47$ really mean in base 8? In base 8, 25 means $2·8 + 5$ and 47 means $4·8+7$. So we're really doing: $$(2·8+5)(4·8+7).$$

We can rewrite this as

$$\begin{array}{lll} \text{64s} & \text{8s} & \text{units} \\ \hline \color{darkblue}{2·4}·8^2 & + \color{purple}{2}·8·\color{purple}{7} + \color{purple}{5·4}·8 & + \color{maroon}{5·7} = \\ \color{darkblue}{2·4}·8^2 & + \color{purple}{(2·7+5·4)}·8 &+ \color{maroon}{5·7}\end{array}$$

The three terms here represent the sixty-fours, eights, and units columns. Now we need to do the carrying.

$\color{maroon}{5·7} = 4·8+3$, so we move the four eights from the units column into the next column to the left:
$$\begin{array}{lll} \text{64s} & \text{8s} & \text{units} \\ \hline \color{darkblue}{2·4}·8^2 &+ \color{purple}{(2·7+5·4\color{maroon}{+4})}·8 &+ \color{maroon}{3}\end{array}$$

and then $\color{purple}{2·7+5·4 + \color{maroon}{4}} = 4·8+6$, so we move the four eights left from the eights column:

$$\begin{array}{lll} \text{64s} & \text{8s} & \text{units} \\ \hline \color{darkblue}{(2·4\color{purple}{+4})}·8^2 & + \color{purple}{6}·8 & + \color{maroon}{3}\end{array}$$

Finally, $ \color{darkblue}{2·4\color{purple}{+4}} = 1·8+4$, so we move the one eight left from the sixty-fours column into a new column:

$$\begin{array}{llll} \text{512s} & \text{64s} & \text{8s} & \text{units} \\ \hline 1 ·8^3 &+ \color{darkblue}{4}·8^2 &+ \color{purple}{6}·8 &+ \color{maroon}{3}\end{array}$$

And in base 8, we abbreviate this to just $$1 \color{darkblue}{4} \color{purple}{6} \color{maroon}{3}$$

which is the answer: $25_8·47_8 = 1463_8$.


Now let's see if we can do the octal multiplication shorthand, without so much toil. We want $$\begin{array}{lll}&2&5\\×&4&7\\\hline \end{array}$$ but with everything in base 8.

We start as usual: $5×7 = 35$… in base 10 we would put down the 5 and carry the 3, but in base 8 we understand it as 4 eights and 3 units, so we put down the 3 and carry the 4:

$$\begin{array}{lll}&2&5^4\\×&4&7\\\hline &&3\end{array}$$

Now $5×4 $ plus the $4$ we carried is $24$, but that's 3 eights and no units, so we put down $30$, not $24$:

$$\begin{array}{lll}&2&5^4\\×&4&7\\\hline 3&0&3\end{array}$$

That $303$ is because $5×47$ is written as $303$ in base 8. Now we continue as usual: $2×7=14$, which is one eight and six units, so we put down the $6$ and carry the $1$:

$$\begin{array}{llll}&&2^1&5^4\\×&&4&7\\\hline &3&0&3\\&&6\end{array}$$

Then $2×4$ plus the $1$ we carried is one eight and one unit, which we put down:

$$\begin{array}{llll}&&2^1&5^4\\×&&4&7\\\hline &3&0&3\\1&1&6\\\hline\end{array}$$

The $116$ is how $2×47$ is written in base 8.

Now we add up the partial products, which is easy; there isn't even any carrying:

$$\begin{array}{llll}&&2^1&5^4\\×&&4&7\\\hline &3&0&3\\1&1&6\\\hline 1&4&6&3\end{array}$$

And 1463 is the answer.