Difficulty: Easy
Correct Answer: 001010₂
Explanation:
Introduction / Context:
Two’s complement is obtained by inverting all bits (one’s complement) and then adding 1. This operation is central to implementing subtraction using a binary adder and to representing negative integers in hardware.
Given Data / Assumptions:
Concept / Approach:
The algorithm is: two’s complement(x) = invert_bits(x) + 1 (within the same bit width). The invert operation flips each 1 to 0 and each 0 to 1. The final addition is performed modulo 2^n, where n is the word size (here n = 6).
Step-by-Step Solution:
Verification / Alternative check:
Check by addition: 110110₂ + 001010₂ = 1000000₂ (a 7-bit result). Discarding the carry beyond 6 bits yields 000000₂, confirming they are complements within 6 bits.
Why Other Options Are Wrong:
110100₂ and 101010₂ are not obtained by invert-plus-one. 001011₂ is off by 1 from the correct complement (it is the one’s complement plus 0).
Common Pitfalls:
Forgetting the final +1 after inversion, or accidentally extending the width during addition.
Final Answer:
001010₂
Discussion & Comments