GATE Computer ScienceVery hardGATE CS (PYQ pattern)
A 4-bit ALU computes A − B as A + B' + 1 and sets C (the adder's carry-out) and V (signed two's complement overflow). Over all 256 ordered pairs (A, B), for how many are C = 1 and V = 1 simultaneously?
- A. 136
- B. 64
- C. 36
- D. 28
Correct answer: D. 28
C = 1 exactly when A ≥ B as unsigned numbers. V = 1 when the signed difference leaves −8..7: either A ≥ 0, B < 0 (A − B ≥ 8) or A < 0, B ≥ 0 (A − B ≤ −9). Unsigned, a negative number (8-15) exceeds every non-negative one (0-7), so only the second case has A ≥ B: A < 0, B ≥ 0 with s(A) − B ≤ −9. With A = −8 + i, need B ≥ i + 1: Σ (7 − i) for i = 0..7 = 28. (Totals: C = 1 in 136 pairs, V = 1 in 64.)
More Digital Logic questions
- A 4-bit two's complement adder computes A + B + Cin. Over all 512 combinations of A, B (each −8 to 7) and Cin (0 or 1), for how many is…
- Over one complete cycle of 10 counts (back to the starting state), how many flip-flop toggles in total does (i) a synchronous 4-bit BCD…
- The 8-bit binary-reflected Gray code of x is g(x) = x XOR (x >> 1). For how many of the 256 values of x does g(x) contain exactly two 1…
- For 8-bit patterns a and b, how many ordered pairs satisfy a > b when both are read as signed two's complement numbers, but a < b when…
- A one-digit BCD adder adds digits a, b (0-9) and a carry-in c (0 or 1). Its 4-bit binary adder gives a carry K and sum Z8Z4Z2Z1, and the…
- Two 8-input priority encoders receive the same inputs I7..I0. Encoder H gives priority to the highest-numbered asserted input, encoder L…