File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes App that performs add. and sub. of arbitrarily large pos int's Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "App that performs add. and sub. of arbitrarily large pos int Watch "App that performs add. and sub. of arbitrarily large pos int New topic
Author

App that performs add. and sub. of arbitrarily large pos int's

R Wall
Greenhorn

Joined: Feb 23, 2006
Posts: 4
I have to implement a application that performs addition and subtraction of arbitrarily large positive integers. In doing so I am not allowed to use any math packages, only ADT's. I beleive a doubly linked list would be easiest and most efficient but am having trouble coding the idea. Thanks.
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1295
How are you thinking of using a LinkedList to implement this? What is your current strategy?


Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16479
    
    2

Personally, I think arrays would be much easier to work with than linked lists. Unless you plan to use the LinkedList class built into the Java API; but even then I think arrays would still be easier.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16680
    
  19

IMHO, I think it would be much easier to determine what Data Structure is best, if we had some idea of what the algorithm, that the original poster was thinking of using. You might get a better answer, and maybe some help, if you give us idea of how you are going to accomplish the task.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
R Wall
Greenhorn

Joined: Feb 23, 2006
Posts: 4
Using an array how would the add method be implemented?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35223
    
    7
Without trying to sound snippy: That's for you to figure out. This sounds like a homework assigment, and we don't do peoples homework for them. If, on the other hand, you have an idea of what to do but have trouble implementing it, then come back here, and we'll be happy to help you get going again.


Android appsImageJ pluginsJava web charts
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16479
    
    2

Originally posted by R Wall:
Using an array how would the add method be implemented?
I don't think I'm giving too much away if I suggest you use some square boxes drawn on a piece of paper to simulate the arrays. Write the numbers in the square boxes, one digit per box. Put one number above the other. Then, try to recall the way you add two numbers (the way you learned when you were about 8 years old but now do without thinking). Convert that into Java code.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: App that performs add. and sub. of arbitrarily large pos int's
 
Similar Threads
converting from timestamp to date
Is this an SQL Antipattern?
Java Numbers
return type in findbycriteria
Own driver