I am wondering how to implement a circular right shift by k of the bitstring represented by the int bits.
public int r
You mean you want the bits rotated off the right-hand side to appear on the left?
return Integer.rotateRight(bits, k);
Example:
int n = 0x55005500; // Binary 01010101000000000101010100000000
int k = 13;
System.err.printf("%08x%n", Integer.rotateRight(n, k));
output:
a802a802 // Binary 10101000000000101010100000000010