So I am trying to solve this home assignment and I have been stuck with this one particular problem for a couple of hours and can't figure it out. I feel like I am so close! But then i change something in the code and something else isn't right..
/*
 * logicalShift - shift x to the right by n, using a logical shift
 *   Can assume that 0 <= n <= 31
 *   Examples: logicalShift(0x87654321,4) = 0x08765432
 *   Legal ops: ! ~ & ^ | + << >>
 *   Max ops: 20
 *   Rating: 3
 */
int logicalShift(int x, int n) {
    int move;
    int y;
    y = x >> n;
    y = ~y << 1;
    move = (y & (x >> n));
    return move;
}
What is missing here? I get 0x80000000 >> 31 as 0 but should be 1 - But other than that I don't know..
 
     
     
     
    