Hi there , I am still confused as to how to convert the decimals to octal values and hexadecimal values in JAVA ??? please help. Thanks, karhik
Sekhar Kadiyala
Ranch Hand
Joined: Feb 17, 2004
Posts: 170
posted
0
Hi Karthik, In Java language you can do that using he methods toOctalString(),toHexString(),toBinaryString methods of the Integer and Long classes. Or are you looking for the general rules of conversion?
PMP CSQA SCJP SCWCD SCBCD INS 21 INS 23
Karthik Gurunathan
Greenhorn
Joined: Jan 26, 2004
Posts: 19
posted
0
Hi sekar, I understand that ,...I am looking for general method of conversion ..exam point of view..if they ask like whats the hexadecimal equivalent for some particular decimal..stuff like that... karthik
Sandhya Harish
Greenhorn
Joined: Feb 15, 2002
Posts: 22
posted
0
to convert a decimal to octal : say the decimal number was 70 - 70/8 = 8, remainder = 6 - 8/8 = 1, remainder = 0 - 1/8 = 0, remainder = 1 therefore, octal eqv of 70 is 0106, u can recheck this by 0*8^3 + 1*8^2 + 0*8^1 + 6*8^0 = 0+64+0+6 = 70 to convert a decimal to hexadecimal: say the decimal number is 125 - 125/16 = 7, remainder = D(13) - 7/16 = 0, remainder = 7 therefore, hexadecimal equivalent of 125 is 7D, u can recheck this by 7*16^1 + 13*16^0 = 112+13 = 125. hope this helped!!
Vicken Karaoghlanian
Ranch Hand
Joined: Jul 21, 2003
Posts: 522
posted
0
Karthik- What you are asking is a very general question, I did a google search for you and came up with lots of hits, they are all worth checking. How to convert between different base types If you have a more specific question, we will gladly answer it.
- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. <br />- What truth? <br />- That there is no spoon!!!