This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Mapping from Hex to Binary  RSS feed

 
Nathan Heimdall
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Campbell Ritchie
Sheriff
Posts: 55324
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should be very easy to convert hex numbers to binary. There is a direct mapping from each hex digit to 4 binary digits.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!