ProgrammingVery hard
The lowest bit that is zero in x = 0b1011 is isolated by ~x & (x + 1). What value does this give?
- A. 8
- B. 1
- C. 4
- D. 2
Correct answer: C. 4
x + 1 is 12, and ~x has zeros where x has ones. The AND gives 0b100, which is 4, the first zero bit above the trailing ones.
More C Programming questions
- With 16-bit unsigned arithmetic, (65535 x 2) & 0xFFFF is what?
- How many multiples of 4 lie between 1 and 100 inclusive?
- What is gcd(84, 36) by the Euclidean algorithm?
- How many divisors does 10 have among 1 through 10?
- int c = 0; for (int i = 0; i < 7; i++) for (int j = 0; j < 7; j++) if (i == j) c++; printf("%d", c); What is printed?
- static int next = 1; int f(void) { return next = 2; } / f is called three times; what does the third call return? /