This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell 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


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Code for addition of two numbers?" Watch "Code for addition of two numbers?" New topic
Author

Code for addition of two numbers?

Nagacharan Lokkidi
Greenhorn

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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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.
 
GeeCON Prague 2014
 
subject: Code for addition of two numbers?