I know about Integer.toBinaryString(int i)
, but what I am trying to decide how to do is append a certain number of bits (0's)
to the end of it as needed.
Example: I have the integer 3
which is represented by 11 in binary
, but I want it to be 7 digits (bits) long in total so it will get the length of the binary value (in this case 2 bits) and then add 5 0's to the start so you will finish with 0000011
for a total of 7 bits
.