Binary Multiplication and Division... (1 Viewer)

Joined
May 27, 2004
Messages
107
Gender
Male
HSC
2004
what is Multiplication and division of Binary.... i got told about it the other day but the person who told me about it coupldnt remember how to do it
 

acmilan

I'll stab ya
Joined
May 24, 2004
Messages
3,989
Location
Jumanji
Gender
Male
HSC
N/A
Multiplication is easy, you just multiply like any normal number and then add.

EG. 25 x 3 = 75
In binary:
11001 x
11
_____
11001 +
110010
______

1001011 = 75
 

acmilan

I'll stab ya
Joined
May 24, 2004
Messages
3,989
Location
Jumanji
Gender
Male
HSC
N/A
DIvision is the same as normal long division except using binary number.
 

Winston

Active Member
Joined
Aug 30, 2002
Messages
6,128
Gender
Undisclosed
HSC
2003
Give me an example and ill show u how to do it, multiplication and division and addition and subtraction are all easy, i found that the IEEE was a little tricky, but logical.
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
dastonecutters said:
and what is it used for...
We'd have to look at things on the processor level to answer this question. As you probably already know, CPUs have instructions sets (op codes) that instruct it what to do with data.

Some CPUs have very limited instruction sets as they might not be designed to perform a particular task.

In the case of a single cycle computer, where every instruction executed must finish within one clock cycle, it may not be possible to perform complex arithmetic like multiplication and division in one clock cycle. Hence, the CPU itself might not actually be able to multiply and divide. *shock horror*

It is then up to the programmer to devise ways to multiple and divide using only adding, subtracting, ANDing, ORing, etc (and whatever else is avaliable to the programmer)

See if can devise a way of multiplying binary numbers with only adding and some logical operators ;)
 
Last edited:

Winston

Active Member
Joined
Aug 30, 2002
Messages
6,128
Gender
Undisclosed
HSC
2003
sunny said:
We'd have to look at things on the processor level to answer this question. As you probably already know, CPUs have instructions sets (op codes) that instruct it what to do with data.

Some CPUs have very limited instruction sets as they might not be designed to perform a particular task.

In the case of a single cycle computer, where every instruction executed must finish within one clock cycle, it is not possible to perform complex arithmetic like multiplication and division in one clock cycle. Hence, the CPU itself might not actually be able to multiply and divide. *shock horror*

It is then up to the programmer to devise ways to multiple and divide using only adding, subtracting, ANDing, ORing, etc (and whatever else is avaliable to the programmer)

See if can devise a way of multiplying binary numbers with only adding and some logical operators ;)
Yep... basically the CPU isnt that smart, the realy main thing it can really do is ADD, nothing but add, subtraction and multiplication and division are all derived from the function of adding, subtraction is repeated addition of a negative binary number, multiplication is repeated addition and division is repeated subtraction... so basically the CPU isnt that smart... but fast... :p
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
This method exploits partial sums and binary multiplcation properties to make it quick and simple.

Say we multiply 1011 and 101. (Anyone reading this from 2021 will recognise this)

Code:
  1011
   101x
---------
  1011
 00000
101100 +
---------
110111
Notice the first partial sum is the same as the multiplicand (1011). The second partial sum is 00000. And the third partial sum is the same as the multiplicand with the two bit shift.

The connection?

Each bit in the first partial sum is the AND of the LSB of the multiplier. Each bit in the second partial sum is the AND of the 2nd bit in the multiplier (with one bit shifted), and, each bit in the third partial sum is the AND of the MSB in the multiplier (with two bits shifted).

So as you can see, you can perform simple multiplication in much less operations than repeated addition using addition, ANDing, and bit shifting.

Very efficient. Coding it of course is a tad more confusing.
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
jm1234567890 said:
you mean the binary shift?
Binary shift gives you multiplication/division by factors of 2. And to determine how many times to shift you need even more operations.
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
raymes said:
todays CPUs typically have multiplication hardwired anyway
No that is not true. Most common CPUs you are used to seeing in commericals have multiplication and division hardwired. CPUs used in embedded systems might not.

The computer engineer/scientist still needs to understand how simple things like these are done and not ignore it simply because they have already been implemented before.
 

raymes

Member
Joined
Jan 21, 2004
Messages
116
Location
Sydney
Gender
Male
HSC
2004
i know that - i didnt say that we dont need to know how to multiply, we certainly do - they need to know that TO wire the operation into the CPU

im just pointing out that todays (PC) CPUs generally have an expansive instruction set that includes complex operations including multiplication
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top