Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiply large numbers

Status
Not open for further replies.

tollar

Programmer
Nov 17, 2000
1
DK
We have some problems to figure out how to multiply large numbers...
We are using strings with each large number in it..
the way we have to calculate it is like this.....
eks.. 1234*1234
on paper we put it up like this..
1234
1234
------
answer: 1522756
we start with multiplying 4*4 =6, 1 to reminder
then 3*4 + 4*3 + reminder=5, 2 to reminder
then 2*4 + 3*3 + 4*2 + reminder=7, 2 to reminder
then 1*4 + 2*3 + 3*2 + 4*1 + reminder=2, 2 to reminder
then 1*3 + 2*2 + 3*1 + reminder= 2, 1 to reminder
then 1*2 + 2*1 + 1 + reminder = 5
then 1* 1= 1
voila we have the answer 1522756..
You notice the cross multiplying here. This is an old multiplying method from India, our teacher sayed:)
our problem is to find the right design on our c++ code, how the algorithm and recursive loop are going to be. Our heads are bursting now, but we hope we can get some hints out there how to solve this "problem".

Lars and Jan..


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top