Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By Fubarable

Thread: Binary to Decimal

  1. #1
    Nightcrawler is offline Member
    Join Date
    Mar 2012
    Posts
    12
    Rep Power
    0

    Default Binary to Decimal

    Can anyone tell me why this is printing the binary variable as 0 instead of printing the scanner.nextInt value that I set the binary variable equal to and how do I fix it? Thanks.

    Binary to Decimal-binary-decimal.jpg

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Binary to Decimal

    You're modifying the binary variable in the while loop. You need to make a copy of it before the while loop and modify the copy.
    Nightcrawler likes this.

  3. #3
    Nightcrawler is offline Member
    Join Date
    Mar 2012
    Posts
    12
    Rep Power
    0

    Default Re: Binary to Decimal

    Oh, got it! Thanks!

  4. #4
    Nightcrawler is offline Member
    Join Date
    Mar 2012
    Posts
    12
    Rep Power
    0

Similar Threads

  1. Decimal to Binary
    By NetJava in forum New To Java
    Replies: 5
    Last Post: 11-18-2011, 03:43 PM
  2. Decimal to Binary
    By DMarsh12 in forum New To Java
    Replies: 4
    Last Post: 10-01-2011, 07:24 PM
  3. Replies: 5
    Last Post: 08-25-2011, 08:32 PM
  4. Decimal to binary, octal to decimal
    By matejm1994 in forum New To Java
    Replies: 3
    Last Post: 12-26-2010, 10:59 AM
  5. Convert binary into decimal
    By WarmRegards in forum New To Java
    Replies: 8
    Last Post: 10-18-2009, 03:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •