Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Whats the easiest way to learn Different bases Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Whats the easiest way to learn Different bases" Watch "Whats the easiest way to learn Different bases" New topic

Whats the easiest way to learn Different bases

Pavneet Kaur

Joined: Oct 09, 2002
Posts: 1
I am looking for a easy and quick way to learn Decimal equivalent in Hex and Octal. Any ideas. What kinda question comes in 1.4 exam for this topic?
Nidhi Juneja

Joined: Oct 07, 2002
Posts: 27
Hi Pavneet...there r 2 options which i know....
first method:
1)for hex-divide the number by 16 and keep the remainder aside.
2)repeat step 1 again and again till u get a number smaller than 16 in which case this will be the remainder.
3)change 10 to A ,11 to B and so on for the remainders.
3)now start traversing the remainders in the reverse order than they were produced.
resulting number is hex equivalent
do the same for octal conversion but this time divide by 8.
second method:
1)convert decimal in to binary
2)for hex-start from the rightmost bit and make groups of 4 bits each. write the hex eq of each group. resulting is the converted value.
3)for octal-make groups of 3 from the right.
we don't get direct questions on conversion but it important to know for fns like tohexstring,tooctalstring and for unicode characters as well...
hope it is clear.
I agree. Here's the link:
subject: Whats the easiest way to learn Different bases
jQuery in Action, 3rd edition