Granny's Programming Pearls "inside of every large program is a small program struggling to get out" JavaRanch.com/granny.jsp
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Bear Bibeault
• Paul Clapham
• Jeanne Boyarsky
• Knute Snortum
Sheriffs:
• Liutauras Vilda
• Tim Cooke
• Junilu Lacar
Saloon Keepers:
• Ron McLeod
• Stephan van Hulst
• Tim Moores
• Tim Holloway
• Carey Brown
Bartenders:
• Joe Ess
• salvin francis
• fred rosenberger

Greenhorn
Posts: 8
Hi Guys,
Can anyone tell me how to convert a Hexadecimal Number to a binary number.
Sathya
Texas Tech University

Greenhorn
Posts: 2
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
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

Originally posted by Sathya Ramanathan:
Hi Guys,
Can anyone tell me how to convert a Hexadecimal Number to a binary number.
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
Thank you Owen. That was a very clear description on how to do the conversion.
Sathya
Texas Tech University

 New rule: no elephants at the chess tournament. Tiny ads are still okay. Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous