I am looking for a sequence of bitwise operations that has the following property:
| 00 01 10 11
---|---------------
00 | 00
01 | 01 01
10 | 00 01 00
11 | 00 01 11 11
The groups of bits operated upon are on the vertical and horizontal margins, the result matrix is symmetrical.
The following code implements what you would like in C/C++.
#include<stdio.h>
int main(void)
{
int i, j;
for(i=0; i<4; i++)
{
for(j=0; j<4; j++)
{
int x = i&j&(i|j)<<1|(i|j)&(~((i^j)&(i^j)>>1)|(i>>1^i))&1;
printf("%d%d ", x>>1, x&1);
}
printf("\n");
}
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With