GATE / CS ARCHIVE

SIMILAR QUESTIONS / DIGITAL LOGIC

Preserve value when widening signed integers

2 questions solved the same way, newest first. Back to Digital Logic

How these are solved

Preserve a two’s-complement value by replicating the sign bit in newly added high positions; distinguish widening from shifts or arithmetic. One asks the operation using sign extension, the other checks concrete wider encodings.

1 mark · MSQ
Report issue

Sign-extending negative two’s-complement numbers

Number Systems & Computer Arithmetic

Question 25, GATE 2025: The four-bit two’s-complement encoding of −6 is 1010. Which wider encodings still represent −6? A eight-bit 10001010; B eight-bit 11111010; C sixteen-bit 1000000000001010; D sixteen-bit 1111111111111010.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: B, D

Step through it (10 steps)

Approach: Extend the sign bit, not zeros, when widening a signed two’s-complement representation.
In w bits, a word with leading bit 1 represents its unsigned value minus 2w. The four-bit word 1010 has unsigned value 10, so 10−16=−6. To preserve that signed value when adding high-order bits, copy the leading 1 into every new position.
For eight bits this gives 11111010, with unsigned value 250 and signed value 250−256=−6. For sixteen bits it gives 1111111111111010, with unsigned value 65530 and signed value 65530−65536=−6. Therefore B and D are correct.
A has unsigned value 138 and thus signed value −118. C has unsigned value 32778 and thus signed value −32758. Merely retaining a single leading 1 and inserting zeros is not valid sign extension; it changes the negative weight of the leading bit without compensating through the new high bits.

Original paper, page 25 · Answer key

1 mark · MCQ
Report issue

Purpose of sign extension

Number Systems & Computer Arithmetic

Question 1.16, GATE 2002: In which operation is sign extension a step?
(A) Floating-point multiplication; (B) Signed 16-bit integer addition; (C) Arithmetic left shift; (D) Conversion of a signed integer from one size to another.
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step 1: Compare zero extension with sign extension.

Step 2: For a positive number, the sign bit is zero, so sign extension simply adds leading zeros. For a negative number, adding leading ones preserves the signed interpretation: 10001 has unsigned value 17−32=−15, and 11110001 has unsigned value 241−256=−15. Zero-extending 10001 would instead yield+17.

Conclusion: When a signed two’s-complement integer is widened, copy its sign bit into the new high-order positions. This preserves the numerical value; for example 10001₂ (5-bit−15) becomes 11110001₂ (8-bit−15). This is the size-conversion operation in D.

Original paper, page 2