File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes JVM going nuts? or is it me? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "JVM going nuts? or is it me? " Watch "JVM going nuts? or is it me? " New topic
Author

JVM going nuts? or is it me?

Brett Swift
Ranch Hand

Joined: May 22, 2002
Posts: 61
65 in Hex:
(6 * 16^1)+5 = 101
65 in Octal:
(6 * 8^1)+5 = 53
HOWEVER:
System.out.println(Integer.toHexString(65)+" Hex");
System.out.println(Integer.toOctalString(65)+" Oct");
prints:
41 Hex
101 Oct
where I thought it would print out:
101 Hex
53 Oct
First: How does the expected 101 get to the Octal value, and where did 41 come from?
Did someone slip me some LSD? Have I been working too hard? Or is my JVM playing a practical joke on me?
Thanks!
Jamal Hasanov
Ranch Hand

Joined: Jan 08, 2002
Posts: 411
You had to devide to 16 and 8, not to multiply
65/16 = 4*16+1 = (HEX)41
(DEC)65 = (HEX)41
65/8 = 8+1 = (OCT)101 (Because 8 is 10 in octal).
(DEC)65 = (OCT)101
That's all
Jamal Hasanov
www.j-think.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JVM going nuts? or is it me?
 
Similar Threads
Question from Khalid's book for SCJP
Hex and Octal
Integer.toOctalString
hex into byte
Ranchers,Clarification on UTF-8 in Java