Try using Integer. ParseInt(binOutput, 2) instead of Integer. ParseInt(binOutput).
Up vote 0 down vote favorite 1 share g+ share fb share tw.
I am trying to translate a String that contains a binary value (e.g. 000010001010011) to it's Hex value.(453) I've been trying several options, but mostly I get a converted value of each individual character. (0=30 1=31) I have a function that translates my input to binary code through a non-mathematical way, but through a series of "if, else if" statements. (the values are not calculated, because they are not standard.
) The binary code is contained in a variable String "binOutput" I currently have something like this: String bin = Integer. ToHexString(Integer. ParseInt(binOutput)); But this does not work at all.
Java string binary hex link|improve this question asked Apr 22 '11 at 21:00Yuri31.
Wow, yo guys are fast! And it works! Thanks!
But I have 1 issue remaining... when the numbers are larger it does not seem to work.(e.g. "1011000010001010011101010110110011001000010011111" should become 16114EAD9909F) – Yuri Apr 23 '11 at 6:33 The problem is that the value does not fit in an int. Try String bin = Long. ToHexString(Long.
ParseLong(binOutput, 2)); If it gets too big for even a long (64 bits), then you're going to have to break binOutput into smaller strings and do each piece separately. – Ted Hopp Apr 24 '11 at 1:16 @Ted thanks! That fixes the problem.
– Yuri Apr 24 '11 at 8:09.
Ted Hopp beat me to it, but here goes anyway: jcomeau@intrepid:/tmp$ cat test. Java; java test 000010001010011 public class test { public static void main(String args) { for (int I = 0; I Println("The value of " + argsi + " is " + Integer. ToHexString(Integer.
ParseInt(argsi, 2))); } } } The value of 000010001010011 is 453.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.