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
In reply to Re^3: Bitwise operations
by BrowserUk
in thread Bitwise operations
by bangor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |