This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma 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
Sheriff

Joined: Oct 14, 2005
Posts: 19725
    
  10

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Code for addition of two numbers?
 
It's not a secret anymore!