views:

143

answers:

4

Multiplication of two integers, like

 a = 38473847837483473894283749832938293872389472847389243847347
 b = 92892382019283923829302392830923890

stored as

a[0] = 3, a[1] = 8 ...

I want to multiply these two over using efficient algorithm (note I stored them in array A and array B). And I want store result in RES[].

How can I do, just give me a algorithm.

+2  A: 

Just use GMP or the like. It is almost certainly going to to contain some of the most efficient code.

jay.lee
there is no algo , in this wen adress , or I couldnt see
fatai
Most efficient, yes, but not so good for a library. Exhausting memory is fatal in GMP.
paxdiablo
+4  A: 

Homework?

Some help might be found here. I suggest seeking to understand this, not just copying it, to get the most from the assignment

List of multiplication algorithms here

Paul
I want algorithm not code , just I said before
fatai
Code is an expression of an algorithm. If you want just the algorithm, why tag it is C? Added a reference to multiplication algorithms anyway
Paul
@User:You dont demand on SO...!
fahad
A: 

Multiplication algorithms can be found here on wikipedia.

Bart van Ingen Schenau
+2  A: 

How would you do it with pencil and paper? That would be a good starting point. Remember the old "shift and add" algorithm. There are much more efficient algorithms but no need to increase the complexity until you have a compelling performance need.

You should also consider storing your numbers in reverse order in your arrays; that is, let a[0] contain the lowest digit (1's), a[1] contain the next lowest (10's), etc. That will allow you to easily align them for operations (addition, etc.).

Finally, realize that base 10 is probably not the most efficient choice for computer implementation (though it can certainly be done).

Drew Hall
If you want to print answers in decimal, base 10^n is by far the most efficient. Otherwise you have a whole 'nother loop of division and remainder (by 10) operations to print the result, which is very expensive.
R..