K & R - Understanding Exercise 2-8: Exactly What Is Set Here?

I am working on the exercises in K & R. I am currently stuck in Exercise 2-8, which states the following:

Write a function rightrot(x, n) that returns the value of the integer x rotated to the right by n bit positions.

I have a problem in that I cannot imagine how the result should look.

How or what am I turning? I take the leftmost bit and put it in the rightmost position x, after it xmoves to the left and repeats this for the bit n? Or do I take a piece ( nbits) and put it in the squares nto the right, leaving the other rightmost bits unchanged?

Any helpful answer is appreciated. Thank.

+5
source share
2 answers

, , , "", .

:

123456789 3 789123456. 123456789 4 567891234.

, n . , , , .

, "" "" "" , .

+6

, .

. . . n .

+1

All Articles