+ 2
convert to from decimal to int to hexadecimal with 8 bits
Hi guys I made a programm to convert decimal to int and to hexadecimal, the problem is that i can't get a function that shows me the 8 bits properly (ceros on the left). That's why I used a trick, which ain't so fancy. If somebody has the solution please leave a comment https://code.sololearn.com/cNVZE3DtwrHu
2 Antworten
+ 2
This should give you the output you want:
for (int counter = 1; counter < 128; counter++) {
String s = "0000000"+Integer.toBinaryString(counter);
System.out.println(s.substring(s.length()-8));
}
+ 2
Thanks I will try it out