This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Mapping from Hex to Binary Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Mapping from Hex to Binary" Watch "Mapping from Hex to Binary" New topic
Author

Mapping from Hex to Binary

Nathan Heimdall
Greenhorn

Joined: Mar 02, 2009
Posts: 20
Hello All,

I have created an implementation of the BigInteger class, which has the option of using numbers input in any base.
I am having problems getting it to scale up for large numbers as I am first converting the input hexadecimal string, character by character into its binary equivalent string.
i.e. 0-0000,1-0001,2-0010 and so on.

This conversion is taking a lot of time because when I input a hex number of 600+ bits it has to match every option until the hex character macthes.

What would be an efficient way to perform this mapping? Is there any Java API or a data structure that I can use to make this process faster?

Thanks,


-Nathan
"A single conversation with a wise man is better than ten years of study."
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37943
    
  22
It should be very easy to convert hex numbers to binary. There is a direct mapping from each hex digit to 4 binary digits.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mapping from Hex to Binary
 
Similar Threads
Sign extension doubt?
conversion of binary and hex to decimal and about left/right shift
hexadecimal?
Charset and special characters
char array