0

I have hexadecimal string of length 80bits like "12345ABCDEF78E9CD741" and need to convert into binary string.

I tried the following code String Skey = "12345ABCDEF78E9CD741"; int i = Integer.parseInt(Skey, 16); String bin = Integer.toBinaryString(i);

But the integer cant hold 80 bits. So how this can be done in java.

2
  • Can you post some code here? Maybe what you have tried. Commented Dec 27, 2013 at 13:04
  • that number is way beyond what an integer can hold Commented Dec 27, 2013 at 13:15

1 Answer 1

1

Parse it to a BigInteger and convert that to binary

BigInteger bigint = new BigInteger("12345ABCDEF78E9CD741", 16);
System.out.println(bigint.toString(2));

Output:

10010001101000101101010111100110111101111011110001110100111001101011101000001

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.