n >>> s

if n is positive then its the same as n >> s

but if n is negative there are two cases:

if n is an int and negative then:

n >>> s = (n>>s)+(2<<~s)

if n is a long and negative then:

n >>> s = (n>>s)+(2L<<~s)

So I would try the following:

static int UnsignedRightShift(int n, int s) //n is an integer

{

if(n > 0){

return n>>s;

}else{

return (n>>s)+(2<<~s);

}

}

static long UnsignedRightShift(long n, int s) //Overloaded function where n is a long

{

if(n > 0){

return n>>s;

}else{

return (n>>s)+(((long)2)<<~s);

}

}