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.
source
share