ProgrammingHard
In a 32-bit unsigned int, what is (~0u) >> 28?
- A. 15
- B. 16
- C. 0
- D. 240
Correct answer: A. 15
~0u is all 32 bits set. Shifting right by 28 leaves the top four bits, all set, which is 15.
More C Programming questions
- What value does a[i] ^= a[j] leave when i and j refer to the same element?
- Which expression sets bit 31 of an unsigned 32-bit variable x with no undefined behaviour?
- The sequence n ^ (n >> 1) for n = 0, 1, 2, 3 gives what list?
- For positive values below 2^31, which product is guaranteed to fit in a signed 64-bit integer?
- What is the multiplicative inverse of 2 modulo 7?
- In C, what is the result of 7 / -2 and 7 % -2?