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
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
Joined: Jul 02, 2002
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>