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???
is there any other way to multiply large nos???
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, tens str, 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:
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.|