GATE / CS ARCHIVE

SIMILAR QUESTIONS / DIGITAL LOGIC

Encode negative integers in two’s complement

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

How these are solved

Choose the stated bit width, encode the magnitude, complement and add one (equivalently 2^n minus magnitude), then compare binary or hexadecimal options. Preserves the existing negative-integer encoding group, adding the hexadecimal-width variant.

1 mark · MCQ
Report issue

Sixteen-bit two’s-complement encoding of −28

Number Systems & Computer Arithmetic

Question 4, GATE 2019: Find the 16-bit two's-complement representation of decimal −28. Choices: A 1111 1111 0001 1100; B 0000 0000 1110 0100; C 1111 1111 1110 0100; D 1000 0000 1110 0100.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Step through it (5 steps)

Method: represent the positive magnitude at the specified width, complement every bit, and add one.

1. Positive 28 is 16 + 8 + 4, so its 16-bit binary representation is 0000 0000 0001 1100.
2. Complement all 16 bits: 1111 1111 1110 0011.
3. Add one: 1111 1111 1110 0100, which is hexadecimal FFE4.
4. Check by the modular interpretation: a negative integer −28 is encoded as 216 − 28 = 65508. FFE4 has unsigned value 65508 and signed value 65508 − 65536 = −28.

Result: C. Setting just the most significant bit would be sign-magnitude encoding, not two's complement; retaining the positive low byte after filling leading ones would also give the wrong number.

Original paper, page 4 · Answer key

1 mark · MCQ
Report issue

Twos-complement representation of negative fifteen

Number Systems & Computer Arithmetic

Question 1.15, GATE 2002: Which bit string is a two’s-complement representation of decimal −15?
(A) 1111; (B) 11111; (C) 111111; (D) 10001.
Question 1.15, GATE 2002: Which bit string is a two’s-complement representation of decimal −15?
(A) 1111; (B) 11111; (C) 111111; (D) 10001.
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step through it (10 steps)

Step 1: Choose a width that can represent the value.

Step 2: The n-bit two’s-complement range is−2n−1 through 2n−1−1. Four bits cannot hold−15, while five bits can. At width five, +15 is 01111; complementing gives 10000 and adding one gives 10001. Interpreting10001 as unsigned 17 and subtracting 32 independently checks−15.

Conclusion: At least 5 bits are needed because the 4-bit signed range is−8 through 7. In5 bits, −15 is 25−15=17=10001₂, D. Strings consisting entirely of ones represent−1, not−15.

Original paper, page 2

2 marks · MCQ
Report issue

Hexadecimal twos complement of negative 539

Number Systems & Computer Arithmetic

Question 2.10, GATE 2001: Choose the three-hex-digit two’s-complement representation of decimal −539 from ABE,DBC,DE5,9E7.
Tap to enlarge
Your answer
Answer & solution

Answer: C for the displayed 12-bit width (no official key was published)

Step through it (5 steps)

Step 1: Convert 539 to hexadecimal:539=2·256+1·16+11=21B₁₆. The three-hex-digit answer options imply 12 bits.

Step 2: Complement each hex digit to F, giving DE4, then add one to obtain DE5. Independently,1000₁₆−021B₁₆=0DE5₁₆.

Thus C. A wider representation would sign-extend with leading F digits; two’s-complement representation is width-dependent, so DE5 is interpreted using the options’ width.

Original paper, page 5