A:
Kuniaki
I have read your technial interview question and they are great! However, this question puzzles me...
First, you are using signed data type. What if you are rotating NEGATIVE values? Then, if you are shifting right, the sign-bit will carry over resulting to an incorrect answer. Second, what if you are rotating by 64 bits (for the second argument for 'rotate')? Theoretically, rotating by 64 should do anything. So before doing all of the masking and shifting, you should mod the second parameter by 32. So you will deal with the leftovers (if there are any).
Thank you! And please keep up the good work!
Kuniaki