# Lecture 2: Ints

**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

- No. Consider where and .
- The operation holds for all values.
- 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.

`0xFF00800F | 0x00FFF000`

`0x00F00FFF ^ 0x00000000`

`0x800F0FFF >> 4`

`(0xFF00FF0 << 8) & 0x000FF0F0`

####Solution

`0xFFFFF00F`

`0x00F00FFF`

`0XF800F0FF`

`0X000F0000`

####