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.
- Line up problem, larger number on top, place values aligned:1111000 x 1111 --------
- Multiply the top number by
1
of the LSB of the bottom number:1111000 x 1111 -------^ 1111000 - 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 - Repeat the same process for the next bit1111000 x 1111 -----^-- 1111000 11110000 111100000
- Repeat the same process for the next bit1111000 x 1111 ----^--- 1111000 11110000 111100000 1111000000
- Add the results together1111000 x 1111 -------- 1111000 <- Add 11110000 <- all 111100000 <- these 1111000000 <- together ---------- 11100001000 <- Final Answer
Instructions
Create a new variable multiply_12_and_6
and set it equal to the binary result of 1100
2 x 110
2
Create another variable multiply_50_and_15
and set it equal to the binary result of 110010
2 x 1111
2