GATE Computer ScienceVery hardGATE CS (PYQ pattern)
An 8-bit two's complement adder computes 3x as (x + x) + x for every x from −128 to 127, setting the overflow flag V separately on each addition. For how many x do BOTH additions set V, and for how many x does the final 8-bit result differ from the true value 3x?
- A. 43 and 171
- B. 0 and 128
- C. 21 and 171
- D. 0 and 171
Correct answer: D. 0 and 171
The first addition overflows when 2x leaves −128..127, i.e. x ≥ 64 or x ≤ −65 (128 values). Its wrapped result 2x ∓ 256 then has the opposite sign to x, and adding numbers of opposite signs can never overflow, so both additions never overflow together: 0. The final result is correct exactly when 3x fits, −42 ≤ x ≤ 42 (85 values), so 256 − 85 = 171 results are wrong (128 with the first V set, 43 with only the second V set).
More Digital Logic questions
- Over all 256 eight-bit patterns, for how many does the value read as sign-magnitude equal the value read as two's complement?
- Over all 256 eight-bit patterns, for how many does the value read as sign-magnitude, as one's complement and as two's complement all…
- The quadratic x² − (13)b·x + (46)b = 0, with coefficients written in base b, has roots 6 and 9. What is b?
- For how many integers n with 2 ≤ n ≤ 30 does the fraction 1/n have a terminating representation in base 6 but a non-terminating one in…
- Values from −1000 to +1000 must be stored with a resolution of at least 0.0001. Design (i) is a two's complement binary fixed-point format…
- How many 8-bit patterns have no two adjacent 1 bits and an even number of 1 bits?