Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   multiply large nos. (http://www.go4expert.com/forums/multiply-large-nos-t12052/)

multiply large nos.

can anybody tell me how to multiply two linked lists??

i want to multiply large nos., consisting of hundreds of digit.
i have stored the nos in link list form as one digit per node.
now how to perform the multiplication???

or

is there any other way to multiply large nos???

 xpi0t0s 15Jul2008 13:04

Re: multiply large nos.

Ew, I wouldn't have chosen linked lists to implement a BigNumber library...

I wrote my large number library using char* to represent numbers, reversed so that units were always str[0], tens str[1], 10^n's str[n]. e.g. 375 was stored as "573", 27 as "72".

Multiplication worked along the lines of long multiplication that I did at school on paper:
375
27x
===
2625 <- this line is 375*7
7500 <- this line is 375*2*10
===
10125 <- this line is the sum of the above two lines

So to implement this you'll need functions to add (which you'll probably already have cos it's easy to add) and to multiply by a single digit. It shouldn't be impossible to do this with linked lists, if you really want to put yourself through that pain.

 All times are GMT +5.5. The time now is 22:34.