The cyclic shift is different from the general displacement of the displacement without the loss of digits. When the loop moves to the left, the left side of the bit padding is used to remove the right end of the word, and when the loop moves to the right, it uses the left side of the padding word that is moved from the right. This situation is used in system programs, and in some control programs.
A data description is provided:
A=01111011, loop left 2-bit correct result: 11101101
Process:
The b=a>> (8-2) is used to obtain the correct position of the normal left-shift loss and the b=00000001 after cyclic displacement.
a=a<<2; left Shift a=11101100
a=a|b; A=11101101
If not with intermediate variable a= (a>> (8-2)) | (A<<2)
Total length N (8 16 32)
Loop left N (a>> (n-n)) | (a>>n)
Loop Right N (a<< (n-n)) | (a>>n)
The bit operation function of C language is one of the distinguishing features of most advanced programming languages, and it can be used to realize some special functions, and the flexible mastery is the basis of programming system program with C program.