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
Joined: Jan 26, 2004
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
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!!
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!!!
subject: how to convert decimals to octal and hexadecimal?