Search:

Type: Posts; User: sci4me

Search: Search took 0.10 seconds.

  1. Replies
    18
    Views
    1,018

    Re: Numbers & Binary

    Oh I see... then.. how do you know which two bits are on... I mean, yes the 6 tells that but.. eh..
  2. Replies
    18
    Views
    1,018

    Re: Numbers & Binary

    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...
  3. Replies
    18
    Views
    1,018

    Re: Numbers & Binary

    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]
  4. Replies
    18
    Views
    1,018

    Re: Numbers & Binary

    Oh, derp. So, loop 3 times... right? That's giving me the same results.
  5. Replies
    18
    Views
    1,018

    Re: Numbers & Binary

    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)...
  6. Replies
    18
    Views
    1,018

    Re: Numbers & Binary

    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...
  7. Replies
    18
    Views
    1,018

    Re: Numbers & Binary

    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...
  8. Replies
    18
    Views
    1,018

    Re: Numbers & Binary

    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...
  9. Replies
    18
    Views
    1,018

    Numbers & Binary

    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)...
Results 1 to 9 of 9