Oh I see... then.. how do you know which two bits are on... I mean, yes the 6 tells that but.. eh..
Type: Posts; User: sci4me
Oh I see... then.. how do you know which two bits are on... I mean, yes the 6 tells that but.. eh..
This is what I have:
boolean[] array = new boolean[3];
for(int i=0; i<3; i++)
{
array[i] = (a & (1 << i)) != 0;
}
works beautifully. I figured this out by printing the result of the...
This is what it's giving me now:
0 [false, false, false]
1 [true, false, false]
2 [false, false, false]
3 [true, false, false]
4 [false, false, false]
5 [true, false, false]
Oh, derp. So, loop 3 times... right? That's giving me the same results.
I think something just clicked in my brain :P
I was forgetting that the pattern I need is binary... so .. essentially I just create a int to binary (in the form of a boolean array, only 3 bits)...
Ok, that makes it a little clearer... but I still don't understand how it gives me my 3 booleans from the one int...
I don't want to ask for code and wont (not that I expect it would be given...
Hmm... I'm fairly new to this kind of logic... I haven't worked with this kind of thing very much. I kind of understood the pseudocode but really don't know how to write it... could you go more into...
It takes an int, 0-7. Outputs a 3 long boolean array. The switch case pretty much explains what it does... If I rewrite the output for each input, you'll get essentially the switch case. I'll do it...
Hey guys. So, I have a piece of code that works:
public static boolean[] sub(int a) {
assert (a >= 0 && a <= 7);
boolean uread = false, uwrite = false, uexecute = false;
switch (a)...