How to multiply binary numbers

Sunday, October 29, 2017

How to multiply binary numbers


Description

Continuing the Bits of Binary series, this episode of House of Hacks shows how to multiple binary numbers. Harley shows how binary number multiplication is as easy as 1 x 1 = 1 and 1 x 0 = 0.

This is the fifth in a series dealing with binary numbers. All the videos in this series can be found on the Bits of Binary playlist.

Here at House of Hacks we do tutorials, project overviews, tool reviews and more related to making things around the home and shop. Generally this involves wood and metal working, electronics, photography and other similar things. If this sounds interesting to you, you may subscribe on YouTube.

Here’s the most recent video.

For a written transcript, go to How to multiply binary numbers

All music by Kevin MacLeod at http://incompetech.com and under Creative Commons License By Attribution 3.0.
Intro/Exit: Hot Swing

Transcript

Do you want to multiply binary numbers together?

In this episode of the House of Hacks, we'll look at how easy this operation really is.

Hi Makers, Builders and Do-It-Yourselfers. Harley here.

The playlist up here contains previous episodes where we looked at what binary numbers are, how to count in binary, how to convert between the more familiar decimal base 10 numbers and binary, and how to do addition and subtraction on binary numbers.

In this episode we'll look at multiplying binary numbers together.

Back when we learned how to multiply decimal numbers in school, we had to memorize a table that looked something like this.

If you know this table, you already know everything there is to know about multiplying binary numbers.

The cool thing is multiplication in binary is exactly the same as decimal except you only use these two rows and columns from the table you've already learned.

And the process is exactly the same too.

Let's take a look at a couple examples and then a couple short cuts.

Let's take seven times three.

Just like in decimal, we first multiply the units and write that down under the equal bar.

Since we're multiplying by 1, we just write down the first number.

Then we add a zero placeholder and multiply by the next column.

Since we're again multiplying by 1, we write down the first number again.

And finally we add the two numbers together to get the total.

1 and 0 is 1.

1 and 1 is two, which in binary is one zero, so we write the 0 and carry the 1.

1 plus 1 plus 1 is three represented in binary as one one, so write the 1 and carry the 1.

Again, 1 plus 1 is 10 so write the 0 and carry the 1.

1 and 0 is again 1 so write the 1 and we're done.

Let's double check this by converting the result to decimal.

Remember each column is a power of two and we add the column values that contain a one.

Looking at the values of the columns we have 16 plus 4 plus 1 which is 21.

Let's do another one. Five times five.

Starting with the units, we multiply by the first number times one and write that down.

We put down a zero placeholder for the next column but notice we're now multiplying by zero.

So we ignore that column since zero times anything is zero, and add another placeholder and move to the next column.

We're again multiplying the first number times one and write it down.

Now we're ready to add.

One and zero is one.

Zero and zero is zero.

One and one is two, so write down the zero and carry the one.

One and zero is one.

Finally zero and one is one.

Giving us the result 11001.

Again, we can verify this by converting to decimal.

So we have sixteen plus eight plus one giving us 25.

There are two shortcuts we can observe.

First, since we're always multiplying by either zero or one, the numbers we're adding together are always nothing for zero or the first number shifted by the column that contains a one in the second number.

So this is a really mechanical process of just writing down the first number multiple times shifted as needed and then adding the numbers together.

As an example, we'll take this random number and multiply it by this random number.

We write down the first number with the units under the second number where the columns contain ones.

We can add placeholder zeros if it makes it easier to keep track of the columns.

And then just add.

The second shortcut is related to multiplying by powers of two.

Let's go back to decimal for a minute.

You probably know the shortcut for multiplying by a power of ten.

For ten, one hundred, one thousand, and so forth, all we have to do is add the appropriate number of zeros to the number we're multiplying.

Three times ten is thirty.

Three times a hundred is three hundred, and so forth.

Binary has a similar concept except it's related to powers of two: two, four, eight, sixteen and so on.

Every time a zero is added to the end of a number, it's the same thing as multiplying by two.

So if we are multiplying by two, we add one zero.

If we're multiplying by four we add two zeros, and so forth.

And since powers of two in binary look just like powers of ten in decimal, we really don't have to think about it.

All we have to do is add zeros and we're done.

In this episode, we looked at how binary multiplication is using all the same ideas as decimal multiplication we're already familiar with.

We also looked at two easy shortcuts to mechanically handle the multiplication and multiplying by powers of two.

Binary is a common non-decimal numeric base, but really, any number can be used as a base for a number system.

Leave a comment below if you've worked with number bases besides decimal and for what purposes.

If this is your first time here at House of Hacks: Welcome, I'm glad you're here and I'd love to have you subscribe.

Through these videos I hope to inspire, educate and encourage makers in their creative endeavors.

In spite of this series, usually this involves various physical media like wood, metal, electronics, photographs and other similar materials.

So subscribe and I'll see you again in the next video.

Thanks for joining me on our creative journey.

Now, go make something.

Perfection's not required.

Fun is!