• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Binar representation of octal & hexadecimal nos

 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may help (Acrobat PDF!)
-Barry
[ August 09, 2002: Message edited by: Barry Gaunt ]
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is a lot easier than converting decimal numbers to binary!.Thanks Dan.
Veena
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic