所以它只是很多位移。的比特是按照以下順序:
現在,第一行中,第一部分保持高比特,設定較低位爲0(掩模是0b11110000),轉移他們4到右側。第二部分確實對於較低的位(掩模是0b00001111),並轉移到左側的相同:
first line, first part: 7654xxxx => xxxx7654 (bits shift to the right)
first line, second part: xxxx3210 =>xxxx (bits shift to the left)
add them together: =>7654
然後,第二行。相同的動作,不同的掩模(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: =>
因此,我們最終,最後,用行動:在b
=>
轉換常數爲二進制看什麼他們的意思。 – Barmar
這會互換4位組,然後是2,然後是1.首先,7654與3210.然後,7632與5410.然後,7531與6420.只是寫這讓我意識到,要解釋它並不容易指點:P – AntonH
逐句通過調試器中的函數,在每個語句後以二進制格式打印'b'。你將會開悟。 – Barmar