This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Code for addition of two numbers? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Code for addition of two numbers?" Watch "Code for addition of two numbers?" New topic

Code for addition of two numbers?

Nagacharan Lokkidi

Joined: Jul 25, 2011
Posts: 9
Hi all, i need a addition program for adding two numbers which should take 1000 digits each number. If anybody knows this code,please help me.
Thanks in advance.
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Normally one would just use BigInteger objects if one wanted to add together two integers with 1000 digits.

However I expect you are asking about some homework problem, in which case BigInteger wouldn't be acceptable. If that's the case, please read these links: DoYourOwnHomework and ShowSomeEffort, and then if you still have a question, don't hesitate to ask that question here.
Sridhar Santhanakrishnan
Ranch Hand

Joined: Mar 20, 2007
Posts: 317
Keep the numbers as two int arrays. Traverse the arrays and add the numbers moving the 'carry' to the preceeding index. Finally print the array.

Hope this helps.
I agree. Here's the link:
subject: Code for addition of two numbers?
jQuery in Action, 3rd edition