GATE Computer ScienceVery hardGATE CS (PYQ pattern)
In C99, int x = −37 (32-bit two's complement), and this implementation's >> on negative values is an arithmetic shift. What are x / 4, x >> 2 and x % 4?
- A. -10, -10 and 3
- B. -9, -9 and -1
- C. -10, -9 and 3
- D. -9, -10 and -1
Correct answer: D. -9, -10 and -1
C99 division truncates toward zero: −37/4 = −9.25 → −9, and x % 4 = x − 4·(x/4) = −37 + 36 = −1. The arithmetic shift floors: −37 >> 2 = ⌊−9.25⌋ = −10. Shifting is not the same as dividing a negative number by a power of two.
Practise more Computer Organization and Architecture questionsComputer Organization and Architecture: notes and key points
More Computer Organization and Architecture questions
- A non-pipelined processor takes the sum of its stage delays (90, 150, 110, 170, 80, 130 ps) per instruction. Its pipelined version has the…
- Which hexadecimal pattern is the IEEE 754 single-precision representation of 0.1 (round to nearest)?
- A 4-stage pipeline has stage delays 240, 160, 320 and 200 ps and a 40 ps latch after each stage. The 320 ps stage is split into two 160 ps…
- A memory has B low-order interleaved banks (bank = word address mod B, any positive integer B). A bank stays busy for 6 cycles after an…
- IEEE 754 half precision has 1 sign bit, 5 exponent bits (bias 15) and 10 fraction bits. What is the smallest positive integer that it…
- A 4-stage pipeline has stage delays 140, 300, 170 and 260 ps and no latch overhead. The slowest stage is duplicated into two identical…