ProgrammingModerateGATE CS · Campus placements
uint32_t x = 0x00F0A8u; what is x & (0u - x) in hexadecimal?
- A. 0xA8
- B. 0x80
- C. 0x10
- D. 0x8
Correct answer: D. 0x8
0u - x is the two's-complement negation modulo 2^32. ANDing it with x isolates the lowest set bit of 0xA8, which is bit 3 with value 0x8.
More C Programming questions
- uint32t n = 0xB6u; the loop while (n) { n &= n - 1; count++; } runs with count starting at 0. What is count when the loop ends?
- uint16t v = 0xFFFFu; v = v << 4; What is v afterwards?
- For unsigned int n = 13, what is n ^ (n >> 1)? This is the binary-reflected Gray code of 13.
- What is the bitwise XOR of all integers from 1 to 10, that is 1 ^ 2 ^ 3 ^ ... ^ 10?
- What is the sum of popcount(i) for i = 1 to 8, where popcount counts the set bits?
- uint8t a = 0x3C, b = 0xA5; the statements a ^= b; b ^= a; a ^= b; run in that order. What are a and b afterwards?