bangor has asked for the wisdom of the Perl Monks concerning the following question:
Compose the 4 bits at the corners of the cell to build a binary index: walk around the cell in a clockwise direction appending the bit to the index, using bitwise OR and left-shift, from most significant bit at the top left, to least significant bit at the bottom left. The resulting 4-bit index can have 16 possible values in the range 0-15.I can see in the docs that the relevant operators are "|" and "<<" but I've no idea how to apply them. 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.
As an aside, if anyone can point me to a perl implementation of this algorithm that would be most useful.
Thanks for any help.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Bitwise operations
by BrowserUk (Patriarch) on Jan 08, 2014 at 19:44 UTC | |
by bangor (Monk) on Jan 08, 2014 at 22:23 UTC | |
by BrowserUk (Patriarch) on Jan 09, 2014 at 05:21 UTC | |
|
Re: Bitwise operations
by SuicideJunkie (Vicar) on Jan 08, 2014 at 20:05 UTC | |
by toolic (Bishop) on Jan 08, 2014 at 20:22 UTC | |
|
Re: Bitwise operations
by hdb (Monsignor) on Jan 08, 2014 at 19:54 UTC |