Question 1 (Easy)

Represent the following numbers in binary (assume -bit length words):

  • to base-.
  • to base-.
  • to base-.

Solutions

  • is the same as
  • is the same as
  • is the same as

Question 2 (Hard)

Addresses learning objectives (1)(3)(6)

You are given this mystery function.

int spooky(int a, int b)
{
    if (b == 0) return a;
    int x = a ^ b;
    int c = (a & b) << 1;
    return mystery(x, c);
}

What does it do?

Question 3 (Medium)

Addresses learning objectives: (1)(2)(3)(5)

Determine which, if any, of the following operations are equal for all values. If they are not always equal, provide a counterexample.

Solution

  1. No. Consider where and .
  2. The operation holds for all values.
  3. The operation also holds for all values.

Question 4 (Easy)

Addresses learning objectives (1)(3)(4)(6)

Find the result of the following bitwise operations.

  1. 0xFF00800F | 0x00FFF000
  2. 0x00F00FFF ^ 0x00000000
  3. 0x800F0FFF >> 4
  4. (0xFF00FF0 << 8) & 0x000FF0F0

####Solution

  1. 0xFFFFF00F
  2. 0x00F00FFF
  3. 0XF800F0FF
  4. 0X000F0000

####