If I have four corners with the values 1,0,0,0 how would I go about building the index - for these values the result should be 7.
Erm. Binary 1000 is 8 not 7. Unless you invert the bits, but I don't see any call for that in a quick scan of the page you linked.
If you have an 4 element array containing the 1s & 0s, you could build the numeric value this way:
@b = qw[ 1 0 0 0 ];; $n = 0; $n <<= 1, $n |= $_ for @b; print $n;; 8 @b = qw[ 0 1 1 1 ];; $n = 0; $n <<= 1, $n |= $_ for @b; print $n;; 7
In reply to Re: Bitwise operations
by BrowserUk
in thread Bitwise operations
by bangor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |