Learn

Now that the fundamentals of addition and subtraction are under our belt, multiplication and division will be a cinch.

The great part about binary multiplication is that you only need to know your multiplication table up to 1!

Binary Numbers Result
0 * 0 0
0 * 1 0
1 * 0 0
1 * 1 1

Yep, it’s really that easy!

Here is the long-form standard decimal multiplication problem, 120 x 15:

120 x 15 ---- 600 + 1200 ---- 1800 <- Final answer

Binary multiplication follows this exact same process, multiply and then add the results together. For larger multiplication problems you would repeat step 3 as many times as the bottom number is long.

Let’s do the same problem, 120 x 15 except in binary.

  1. Line up problem, larger number on top, place values aligned:
    1111000 x 1111 --------
  2. Multiply the top number by 1 of the LSB of the bottom number:
    1111000 x 1111 -------^ 1111000
  3. Add a 0 to the next row and multiply all the top numbers by the next LSB (repeat as necessary):
    1111000 x 1111 ------^- 1111000 11110000
  4. Repeat the same process for the next bit
    1111000 x 1111 -----^-- 1111000 11110000 111100000
  5. Repeat the same process for the next bit
    1111000 x 1111 ----^--- 1111000 11110000 111100000 1111000000
  6. Add the results together
    1111000 x 1111 -------- 1111000 <- Add 11110000 <- all 111100000 <- these 1111000000 <- together ---------- 11100001000 <- Final Answer

Instructions

1.

Create a new variable multiply_12_and_6 and set it equal to the binary result of 11002 x 1102

2.

Create another variable multiply_50_and_15 and set it equal to the binary result of 1100102 x 11112

Take this course for free

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?