[prev] 25 [next]

Exercise 4: Bitwise Operations

Given the following variable declarations:

    // a signed 8-bit value
signed char x = 0b01010101;
    // an 8-bit value
unsigned char y = 0b11001100;

What is the value of each of the following expressions:

  • (x & y)
  • (x ^ y)
  • (x << 1)
  • (y << 2)
  • (x >> 1)
  • (y >> 1)
  • (x << 3)
  • (y << 9)
  • (x >> 8)