Answer
(a) 11100101
(b) 00000011
(c) 00010101
(d) 00001000
(e) 11101110
Work Step by Step
To convert decimal to 2's complement use following steps -
If decimal is positive:
1- Convert the number to binary.
2- Pad 0's on left side to get required number of bits.
If decimal is negative:
1- Convert the number to binary.
2- Pad 0's on left side to get required number of bits.
3- Flip all bits.
4- Add 1 to get final result.
a. -27
Absolute value: 27 → 00011011
Invert: 11100100
Add 1: 11100101
Result: 11100101
b. 3
Positive → binary: 00000011
Result: 00000011
c. 21
Positive → binary: 00010101
Result: 00010101
d. 8
Positive → binary: 00001000
Result: 00001000
e. -18
Absolute value: 18 → 00010010
Invert: 11101101
Add 1: 11101110
Result: 11101110