1 2 Previous Next 21 Replies Latest reply: Dec 1, 2006 6:00 AM by 800282 Go to original post
• ###### 15. Re: converting from int to char
I am not being ungrateful about your help or anthing promo I was simply telling you that my binary calculations arent working properly after the update
• ###### 16. Re: converting from int to char
If i try to convert the number 10 to binary the output is being shown as 49484948
• ###### 17. Re: converting from int to char
Sorry about that promo I really do appreciate your help mate and I have just realised that the problem was in the CharacterStack itself as I had it set up to accept integers only :-( bah lol

Thank you again and I really do appreciate your help : )

Cheers
JP
• ###### 18. Re: converting from int to char
...
... arent working properly after the update
That doesn't tell me much. You need to be specific; I'm no mindreader.

The method I posted was just a (slightly) better version of yours. I didn't look at the rest of your code.
You can't stuff an int into my (or your) method and expect to get the hexadeciaml representation of that decimal number. You'll first have to do some calculations of course.

For example: if you have the decimal value of 2744, you first do:
``````2744 = 16 * 171, rest value: 8
171  = 16 * 10 , rest value: 11
10   = 16 * 0  , rest value: 10``````
No you have the values 10, 11, and 8. Use those three values on your (or my) conversion method, and you'll ens up with the characters 'A', 'B' and '8'.

Be carefull not to add the characters to each other!
``````// wrong!
System.out.println('A'+'B'+'8');

// ok
String s = ""+'A'+'B'+'8';
System.out.println(s);``````
• ###### 19. Re: converting from int to char
Sorry about that promo I really do appreciate your
help mate
No need to apologise; no harm done.

and I have just realised that the problem
was in the CharacterStack itself as I had it set up
to accept integers only :-( bah lol
Good you figured it out.

Thank you again and I really do appreciate your help
: )

Cheers
JP
No problem, and you're welcome.
• ###### 20. Re: converting from int to char
my java guru :D
• ###### 21. Re: converting from int to char
my java guru :D
Nah, when you're finished with your Java course, you'll say: "what was all the fuss about?", and you'll know that I'm no guru.
But thanks!
; )
1 2 Previous Next