ProgrammingHard
For unsigned x = 40 (binary 101000), what is x & -x?
- A. 40
- B. 8
- C. 16
- D. 1
Correct answer: B. 8
The expression isolates the lowest set bit, which is bit 3 with value 8. Unsigned negation wraps modulo 2^32.
More C Programming questions
- Reversing the 8 bits of 0b00010110 gives which value in decimal?
- The Gray code of 5 (binary 101), computed as n ^ (n >> 1), is which value?
- What is the parity of the number of set bits in 0b1011, so that the result is 1 when odd?
- What is the value of 2 + 3 << 1 & 7 in C?
- What is the value of 5 ^ 3 & 1 in C?
- unsigned int u = 1; int s = -2; printf("%u", u + s); What is printed with 32-bit unsigned int?