in reply to Re: Bitwise operations
in thread Bitwise operations

Hi BrowserUK, thanks for your reply. The Wikipedia page is confusing me more now - if you have a chance to look at it again you will see in the second grid diagram with the green lines each cell has a number which I believe corresponds to the binary index of the 4 corners.

The top row has cells with the corners
0 0 1 0
0 0 1 1
0 0 1 1
0 0 0 1
and the values in the diagram are 13,12,12,14

But when I apply the bitwise operations I get 2,3,3,1

If I flip the values of the corners before applying the operation I get the correct results, so maybe the algorithm is missing a step or, more likely, I am completely misreading it.

Replies are listed 'Best First'.
Re^3: Bitwise operations
by BrowserUk (Patriarch) on Jan 09, 2014 at 05:21 UTC
    If I flip the values of the corners before applying the operation I get the correct results, so maybe the algorithm is missing a step or, more likely, I am completely misreading it.

    I see the problem. I didn't write the article :) (It is unfortunately quite typical.)

    (Perhaps the explanation is the annotation that reads: "Give every cell a number based on which corners are true/false.")

    You can 'flip' the values after you've constructed them using:

    @b = qw[ 1 0 0 0 ];; $n = 0; $n <<= 1, $n |= $_ for @b; $n = ~$n & 0xf; ## Additional step to bitwise-not +and mask (flip) values. print $n;; 7

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.