Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need Help: Recursive Code -- > Loop

 
Wolfgang Obi
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm having problems with following code segments....
'trying to make loop out of the first part...but something seems to be going wrong.

can anyone see my mistake.....?

thanks.
___________________________________________________________________



[ April 10, 2006: Message edited by: Wolfgang Obi ]

[ April 10, 2006: Message edited by: Wolfgang Obi ]
[ April 10, 2006: Message edited by: Wolfgang Obi ]
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does the schritt01 method do? It's not defined in the posted code.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, I think I see. These methods are supposed to give a binary representation of the input int, right? And schritt01 basically concatenates a char to the output.

If you add the following test code...

...and then run with a command line argument (for example, 1234567), you will see that recu03 does give the correct binary representation. However, iter03 is in reverse order and missing a digit.

H:\Java>java Tester 1234567
100101101011010000111
100101101011010000111
11000010110101101001 <== REVERSED AND MISSING DIGIT

That should suggest where the problem is.
 
Wolfgang Obi
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Marc!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic