wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes hexadecimal Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "hexadecimal" Watch "hexadecimal" New topic
Author

hexadecimal

nitin sharma
Ranch Hand

Joined: Feb 24, 2001
Posts: 290
can anybody teach me the way to find the hexadecimal and octal number of a given decimal?.Please help me immediately, i have just 4 day's left for my paper.
Percy Densmore
Ranch Hand

Joined: Mar 06, 2001
Posts: 214
Nitin,
Just do a search on 'hexadecimal octal' above and you will see several discussions and links at this site :-)
Percy
sai challa
Ranch Hand

Joined: Feb 06, 2001
Posts: 54
1.To find the hexadecimal number of a given decimal:
Divide the decimal number by 16,divide the quotient obtained
by 16 and store the remainder at each step.keep dividing the quotient by 16 at each step until quotient becomes 0.The remainders at each step taken in reverse order is the hexadecimal number.I would like to illustrate with an example.
decimalno:=1000
1.dividend1=1000 divisor=16 quotient1=62 remainder1=8
Now for the second step dividend2=quotient1
2.dividend2=62 divisor=16 quotient2=3 remainder2=E(decimal 14=hexadecimal E)
3.dividend3=quotient2=3 divisor=16 quotient3=0 remainder3=3
since quotient3=0 the hexadecimal number for 1000=(remainder3 remainder2 remainder1)
=(3E8)
To obtain the octal number of a decimal number repeat the above process by 8.
for 1000 the octal number would be:
1 dividend1=1000 divisor=8 quotient1=125 remainder1=0;
2.dividend2=quotient1=125 divisor=8 quotient2=15 remainder2=5
3. dividend3=quotient2=15 divisor=8 quotient3=1 remainder3=7
4.dividend4=quotient3=1 divisor=8 quotient4=0 remainder4=1
since quotient4=0 octalnumber=(remainder4 remainder3 remainder2 remainder1)=(1750)

nachiket deshpande
Ranch Hand

Joined: Oct 06, 2000
Posts: 114
Hi Nitin!
let me try if i can help you.
1)to convert decimal to octal
remember octal numbers are from 0 to 7 i.e.
decimal 0 is octal 0
decimal 1 is octal 1
......
......
decimal 7 is octal 7
if i want to convert 19 to octal i will devide 19 by 8 and write the remainders in reverse order to get a octal number.see how it happens
19/8 gives Quotient=2
Remainder=3
now devide 2(ie the Quotient) by 8
gives Quotient=0
Remainder=2
now writing remainders in reverse order gives octal number=23
19(in decimal)=23(in octal)
2)to convert decimal to hexadecimal
hexadecimal numbers run from decimal 0 to decimal 15.but written as 0,1,2,3,4,5,---9,A,B,C,D,E,F
to convert a decimal to hexadecimal devide the number by 16 and write the remainders in reverse order.lets take an example.
to convert decimal 49 in hexadecimal
49/16 gives Quotient=3
Remainder=1
deviding 3( ie Quotient) by 16
gives Quotient=0
Remainder=3
now write decimal in reverse order
49(in decimal)=31(in hexadecimal)
(remember you have to keep deviding the quotient by the divisor
till the quotient becomes zero)
hope this helps
nitin sharma
Ranch Hand

Joined: Feb 24, 2001
Posts: 290
hello nachiket,
Thank's a lot,U make's handling of bit's, binary,hexa, octa etc look's very easy.I get the feeling whenever i am in trouble in handling bit's i should alway's contact u.
I wish that i should get atleast two to three question's on hexa and octa in the exam.
Once again,Thanks' a lot.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hexadecimal