所以这只是很多位移。这些位的顺序如下:
76543210
现在,第一行,第一部分保留高位,将低位设置为 0(掩码为 0b11110000),将它们向右移动 4。第二部分对低位执行相同的操作(掩码为 0b00001111),然后向左移动:
first line, first part: 7654xxxx => xxxx7654 (bits shift to the right)
first line, second part: xxxx3210 => 3210xxxx (bits shift to the left)
add them together: => 32107654
然后,第二行。相同的操作,不同的掩码(分别为 0b11001100 和 0b00110011),具有32107654
:
second line, first part: 32xx76xx => xx32xx76 (bits shift to the right)
second line, second part: xx10xx54 => 10xx54xx (bits shift to the left)
add them together: => 10325476
第三行与其他掩码(分别为 0b10101010 和 0b01010101)相同,其中10325476
:
third line, first part: 1x3x5x7x => x1x3x5x7 (bits shift to the right)
third line, second part: x0x2x4x6 => 0x2x4x6x (bits shift to the left)
add them together: => 01234567
所以我们最终以行动结束:
76543210 => 01234567