ProgrammingHard
For positive values below 2^31, which product is guaranteed to fit in a signed 64-bit integer?
- A. (10^9 + 6) x (10^9 + 6)
- B. (10^10) x (10^10)
- C. (2^32) x (2^32)
- D. (10^12) x (10^12)
Correct answer: A. (10^9 + 6) x (10^9 + 6)
(10^9 + 6)^2 is about 10^18, below 9.2 x 10^18 for signed 64-bit. The other products exceed 2^63.
More C Programming questions
- What is the multiplicative inverse of 2 modulo 7?
- In C, what is the result of 7 / -2 and 7 % -2?
- An unsigned short variable holds 65535 and is then incremented once with x++. What value does it hold?
- Which statement about left-shifting a negative signed integer in C is correct?
- How many subsets of {1, 2, 3, 4} (including the empty set) have XOR equal to 0?
- What is the result of (0xFFu >> 4) | (0x0Fu << 4) & 0xFF?