Your question is Embedded Coding With Bit Shifts. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Samsung Semiconductor Inc (US) firmware frequently manipulates fixed-width register values. Implement a function that rotates the bit pattern of a 32-bit integer to the right by n positions.
A right rotation moves the least significant bit to the most significant position, while shifting every other bit one position right. The operation must behave as if the value contains exactly 32 bits, even though Python integers have arbitrary precision.
Implement rotate_right(value, n):
value is a signed 32-bit integer in the range [-2^31, 2^31 - 1].n is a nonnegative integer. Rotations larger than 31 must wrap around modulo 32.[0, 2^32 - 1].def rotate_right(value, n):