pleas help me
Write an algorithm to add and multiply two large integers, which cannot be
represented by built-in types.

Edited by miracle Kimuli

2
Contributors
1
10
Views
5 Years
Discussion Span

It's an old school type solution, but I used three int arrays. One for each of the two numbers' digits to go into, and one to hold the "carry" value.

Imagine they are stacked up on top of each other. One digit ONLY per element of each array. Any value > 9, puts the "carry value, into the carry array with the proper (next) index.

Work from the one's column (far right hand side), or you can make it a bit easier and reverse the number, and work from the left hand side (so the indices get bigger in the array's as you loop from first to last digit columns.

Start with a small 3 digit number and see which way you prefer and get the logic worked out, before you jump to bigger numbers.

The process is EXACTLY the same as if you were multiplying numbers together by hand, in grade school.

Laying it out first by hand, (pen and paper) a few times, is a worthwhile experience, since we're so used to using calculators all the time.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.