binary multiplication?

Alex

Diamond Member
Oct 26, 1999
6,995
0
0
ok i kinda get addition and subtraction but multiplication kills me

whats the rule?

for example our prof gave us this (just found out its from google, lol)

Rules of Binary Multiplication
0 x 0 = 0
0 x 1 = 0
1 x 0 = 0
1 x 1 = 1, and no carry or borrow bits
For example,

00101001 × 00000110 = 11110110

0 0 1 0 1 0 0 1 = 41(base 10)
× 0 0 0 0 0 1 1 0 = 6(base 10)
--------------------------------------------------------------------------------
0 0 0 0 0 0 0 0
0 0 1 0 1 0 0 1
0 0 1 0 1 0 0 1
--------------------------------------------------------------------------------

0 0 1 1 1 1 0 1 1 0 = 246(base 10)

i dont get any of the lines of work between the dotted lines :(

can anyone help plz?
 
 

beer

Lifer
Jun 27, 2000
11,169
1
0
From one line to the next, you have to shift one binary place to the left. It's just like base10 multiplication. Take the rightmost place on the 2nd operand. If the value is 0, then your row is straight 0s. If it is a 1, then the row is identical to the first operand. Then do it again with the next binary digit, but shift it one bit to the left. I don't know any other wayto really explain it....
 

XZeroII

Lifer
Jun 30, 2001
12,572
0
0
Think back to 2nd grade when you learned to multiply. It's the exact same thing.
 

Alex

Diamond Member
Oct 26, 1999
6,995
0
0
Originally posted by: Elemental007
what kind of major are you where that is a midterm content?

im second-year comp sci major...

they have us learn binary arithmetic etc for an assembler course :(
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
Originally posted by: franguinho
well as it turns out it wasnt in my midterm! phew! :)
Then it will be on the final so you'd better learn it :)

And yes, it is just shift-and-add the original for each digit in what you're multiplying it by. You can try it yourself with normal decimal multiplication just by making the multiplier a number like "101":

55
x 101
-------
= 55 + 0 * 10 (shifted once) + 55*100 (that is, 55 shifted twice)

Binary operations might seem useless to you now but they're used heavily in hardware, in compact file formats like SWF (Shockwave Flash), in efficient data structures, and in option flags for API calls. Usually it's just shifts and masks rather than multiplication and division though.
 

Alex

Diamond Member
Oct 26, 1999
6,995
0
0
Originally posted by: DaveSimmons
Originally posted by: franguinho
well as it turns out it wasnt in my midterm! phew! :)
Then it will be on the final so you'd better learn it :)

And yes, it is just shift-and-add the original for each digit in what you're multiplying it by. You can try it yourself with normal decimal multiplication just by making the multiplier a number like "101":

55
x 101
-------
= 55 + 0 * 10 (shifted once) + 55*100 (that is, 55 shifted twice)

Binary operations might seem useless to you now but they're used heavily in hardware, in compact file formats like SWF (Shockwave Flash), in efficient data structures, and in option flags for API calls. Usually it's just shifts and masks rather than multiplication and division though.


whoa hmm this shifting this is more complicated than i though but i kinda get it now...