| Author |
Binar representation of octal & hexadecimal nos
|
Veena Pointi
Ranch Hand
Joined: Jun 20, 2002
Posts: 442
|
|
How to convert hexadecimal & octal numbers to binary?Should I convert them first to decimal & then to binary?Can someone explain with example? Thanks Veena
|
SCJP1.4
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill
|
 |
Dan Chisholm
Ranch Hand
Joined: Jul 02, 2002
Posts: 1865
|
|
Veena, You certainly should not convert to decimal before converting to binary. The only reason for the popularity of octal and hex is the fact that both are very easy to convert to binary. Each hex character represents four bits. To convert hex to binary, just write down the four bits that represent each hex character. 0x1234 = 0001 0010 0011 0100 What could be easier than that? Three octal characters are needed to represent a single 8-bit byte. The two characters on the right each represent three bits so both of the rightmost characters represent the six least significant bits of the byte. The third character from the right represents the two most significant bits. Java uses a leading zero as a prefix that indicates that the number is octal. 0123 = 01 010 011 0311 = 11 001 001 011 = 00 001 001 01 = 00 000 001 Octal was very popular when most computers were eight bit machines. Hexadecimal is a better representation when the data values are composed of more than one byte.
|
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
|
 |
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
|
|
This may help (Acrobat PDF!) -Barry [ August 09, 2002: Message edited by: Barry Gaunt ]
|
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
|
 |
Veena Pointi
Ranch Hand
Joined: Jun 20, 2002
Posts: 442
|
|
It is a lot easier than converting decimal numbers to binary!.Thanks Dan. Veena
|
 |
 |
|
|
subject: Binar representation of octal & hexadecimal nos
|
|
|