Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: InfiniteInt and Doublely Linked List, trying to add two together

  1. #1
    Junior Member
    Join Date
    Nov 2018
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    .
    Last edited by Aeoip9; November 27th, 2018 at 11:55 PM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: InfiniteInt and Doublely Linked List, trying to add two together

    should return 555,333,333 but it gives me 555,333,777.
    It looks like the 222 was added to the last group instead of being subtracted.
    Is the sign being lost?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: InfiniteInt and Doublely Linked List, trying to add two together

    Can you post the console's contents that shows what you are asking about?
    Add some comments (<<<<< HERE) to mark and describe where the issue is.

    I'm not sure if im using the negative signs correctly
    Probably not. How are you trying to debug the code to see where the problem is?
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: InfiniteInt and Doublely Linked List, trying to add two together

    Work on one problem at a time. Pick one of the cases where the code fails and do some debugging to see why it doesn't get the desired results.
    For debugging, I use print statements to show the values of variables as they are used and their values are changed.

    Make a test case that only does one call to add with parameters that are not being added correctly.

    Comments on the code:
    There are a lot of places where the code is not properly formatted. The indentations of statements and the alignment of { and } don't show the logical nesting of statements making the code harder to read and understand.
    There are very few comments in the add() method.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [Linked List] Problems deleting items from a linked list
    By KLVTZ in forum What's Wrong With My Code?
    Replies: 7
    Last Post: March 8th, 2013, 09:21 PM
  2. [Linked List] Problems deleting items from a linked list
    By KLVTZ in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 8th, 2013, 07:52 PM
  3. Add an object to a linked list and a database
    By a21j92 in forum JDBC & Databases
    Replies: 0
    Last Post: March 2nd, 2013, 10:09 AM
  4. trouble with add and remove method on doubly linked list
    By BetterCallSaul in forum What's Wrong With My Code?
    Replies: 9
    Last Post: July 22nd, 2012, 07:12 PM
  5. trouble with add and remove method on doubly linked list
    By BetterCallSaul in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 20th, 2012, 02:51 PM