• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hexadecimal Numbers

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,
Can anyone tell me how to convert a Hexadecimal Number to a binary number.
Thanks in advance
Sathya
Texas Tech University
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One hex digit represent 4 binary digits. The max value a hex
can have is F (decimal 15) which is 1111 in binary. The way I
approach it is to use base 10 (decimals) as an intermediary between them like this:
F = decimal 15, decimal 15 = 1111 binary
E = decimal 14, decimal 14 = 1110 binary
D = decimal 13, decimal 13 = 1101 binary
So if you have a larger hex number, you just apply this to each
hex digit.
0x4A:
4 = decimal 4 = 0100 binary
A = decimal 10 = 1010 binary
Answer = 0100 1010
0xEC13
E = decimal 14 = 1110 binary
C = decimal 12 = 1100 binary
1 = decimal 1 = 0001 binary
3 = decimal 3 = 0011 binary
Answer = 1110 1100 0001 0011
Owen
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sathya Ramanathan:
Hi Guys,
Can anyone tell me how to convert a Hexadecimal Number to a binary number.
Thanks in advance
Sathya
Texas Tech University


The Integer.parseInt( String s, int radix ) method can be used to convert a hexadecimal String representation of a number to an int. The Integer.toBinaryString( int i ) method can then be used to convert that int to a binary representation in a String.
 
Sathya Ramanathan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Owen. That was a very clear description on how to do the conversion.
Sathya
Texas Tech University
 
Think of how stupid the average person is. And how half of them are stupider than that. But who reads this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic