hi ppl..
i have some code which reads a txt file, and then converts to binary. my problem is that i need it all to be 12bit. but not all of them come out like that.
how can i fill the "result" with 0's (zeros), from left to right till its 12??? i had a go at masking...but i am having trouble understanding that. thanx!!!
thankx ppl....
here is a bit of my code, i dont know if it will help understand;
for (int i = 0; i < data.length; i++)
{
instruction[i] = Integer.valueOf(data[i]).intValue();
}
//pc = addresses[0];
for (int j = 0; j < data.length; j++)
{
binary[j]= Integer.toBinaryString(instruction[j]);
System.out.println(binary[j]);
i have some code which reads a txt file, and then converts to binary. my problem is that i need it all to be 12bit. but not all of them come out like that.
how can i fill the "result" with 0's (zeros), from left to right till its 12??? i had a go at masking...but i am having trouble understanding that. thanx!!!
thankx ppl....
here is a bit of my code, i dont know if it will help understand;
for (int i = 0; i < data.length; i++)
{
instruction[i] = Integer.valueOf(data[i]).intValue();
}
//pc = addresses[0];
for (int j = 0; j < data.length; j++)
{
binary[j]= Integer.toBinaryString(instruction[j]);
System.out.println(binary[j]);